must declare a named package eclipse because this compilation unit is associated to the named module

主宰稳场 提交于 2020-06-22 05:30:09

问题


I just downloaded eclipse for Java Yesterday but when I was trying to get make my first program, I kept on getting this error:

must declare a named package eclipse because this compilation unit is associated to the named module x. 

How do I fix this?


回答1:


Just delete module-info.java at your Project Explorer tab.




回答2:


The "delete module-info.java at your Project Explorer tab" answer is the easiest and most straightforward answer, but

for those who would want a little more understanding or control of what's happening, the following alternate methods may be desirable;

  • make an ever so slightly more realistic application; com.YourCompany.etc or just com.HelloWorld (Project name: com.HelloWorld and class name: HelloWorld)

or

  • when creating the java project; when in the Create Java Project dialog, don't choose Finish but Next, and deselect Create module-info.java file


来源:https://stackoverflow.com/questions/53033899/must-declare-a-named-package-eclipse-because-this-compilation-unit-is-associated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!