[英]“The declared package '' does not match the expected package ”AssignmentOne.java“” -Java -VS Code
Why am I getting this error in VS Code?为什么我在 VS Code 中收到此错误?
Things I've tried:我尝试过的事情:
I am attempting to only run the file, ScannerInputDemo.java
, but VSCode is also attempting to run the other .java
files in my /Intro To Java
folder.我试图只运行文件ScannerInputDemo.java
,但 VSCode 也试图在我的/Intro To Java
文件夹中运行其他.java
文件。
I've tried modifying my launch.json
file to remove the configuration for the AssignmentOne.java
file hoping that it wouldn't attempt to read that file我尝试修改我的launch.json
文件以删除AssignmentOne.java
文件的配置,希望它不会尝试读取该文件
Specs : I'm using a Mac Book Pro 13", mid 2009.规格:我使用的是 Mac Book Pro 13",2009 年中。
My version check is:我的版本检查是:
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.7+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.7+10, mixed mode)
VSCode Version: VSCode 版本:
Version: 1.45.1
Commit: 5763d909d5f12fe19f215cbfdd29a91c0fa9208a
Date: 2020-05-14T08:33:47.663Z (2 wks ago)
Electron: 7.2.4
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 15.6.0
Below is a screenshot of my VS Code window showing the file hierarchy and debug results.下面是我的 VS Code window 的屏幕截图,显示了文件层次结构和调试结果。
I encountered the same issue.我遇到了同样的问题。
Issue was in .classpath
file, present in the project directory.问题出现在项目目录中的.classpath
文件中。
It contained它包含
classpathentry kind="src" output="target/classes" path="src"
I updated it to我将其更新为
classpathentry kind="src" output="target/classes" path="src/main/java"
and it worked.它奏效了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.