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

后端 未结 3 1451
挽巷
挽巷 2020-12-24 00:56

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          


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-24 01:25

    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

提交回复
热议问题