Search code examples
javaeclipsejava-package

Run Java Code without a package in Eclipse IDE


I want to run my code without creating a package in java eclipse IDE.

But when I do so it is showing error :

Must declare a named package because this compilation unit is associated to the named module 'Games'

Solution

  • You are using the Java Platform Module System (JPMS) which requires not to use the default/unnamed package.

    In the default package delete the file module-info.java to not use JPMS and to be able to have code in the default package.