eclipse 线程“main”中的异常java.lang.Error:未解析的编译
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13226238/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Exception in thread "main" java.lang.Error: Unresolved compilation
提问by Pradit
The declared package "" does not match the expected package "src"
I am trying to compile this program and I get the above error.
I imported the project from the downloads folder and copied it to my workspace. Do i need to create a new package ?
The declared package "" does not match the expected package "src"
我正在尝试编译此程序,但出现上述错误。我从下载文件夹中导入了项目并将其复制到我的工作区。我需要创建一个新包吗?
What am i doing wrong ?
我究竟做错了什么 ?
回答by smk
I am not sure exactly what you have done.. But it looks like you havent imported it into the workspace correctly.
我不确定你到底做了什么..但看起来你没有正确地将它导入到工作区中。
If this is a project you have downloaded , just use import-> existing projects into workspace.
如果这是您下载的项目,只需使用 import-> existing projects into workspace 即可。
回答by Bernard
There is a
有一个
default package
默认包
under the src and if you put classes under that it will works fine. The other solution is to create a project manually and add one class and copy paste individually which is not so pleasant.
在 src 下,如果你把类放在它下面,它会正常工作。另一种解决方案是手动创建一个项目并添加一个类并单独复制粘贴,这不太愉快。
回答by Bhavik Ambani
I thik you will have to configure your source location for the project. Do the following thing stated in the image below. Click on "Add Folder" and the location of the source folder
我认为您必须为项目配置源位置。执行下图中所述的以下操作。单击“添加文件夹”和源文件夹的位置
回答by Mohsen
It is happened because your class is not in correct package, you should put your class under defaults package then your issue will be fine; otherwise you should write in top of your class ,your package name for example " mohsen package;"
发生这种情况是因为您的类不在正确的包中,您应该将类放在 defaults 包下,然后您的问题就会好起来;否则你应该在你的班级的顶部写上你的包名,例如“mohsen package;”
回答by Vinodh
You would have removed the package name in any of the class by mistake. Inspect all the classes for correct package name.
您可能会错误地删除任何类中的包名称。检查所有类以获取正确的包名称。
回答by akshat
make sure your 'S' is capital in System.out.println();
确保 System.out.println() 中的“S”是大写的;