InvalidModuleDescriptorException when running my first java app
I have started learning Java and encountered a problem when trying to run my first program as given below:
public class HelloWorld {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Hello world!");
}
}
On Eclipse Photon I encounter this error when running it:
Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: C:\Users\Thomas\eclipse-workspace\HelloWorld\bin
Caused by: java.lang.module.InvalidModuleDescriptorException: HelloWorld.class found in top-level directory (unnamed package not allowed in module)
I looked and there is my .class file in bin directory and my .java in the src
directory.
Is that normal? How do I fix that?
Solution 1:
I was getting the same error. Deleting the module-info.java file solved it for me.
Solution 2:
It seems that you haven't created a package. My usual procedure in Eclipse is:
- Create a new Java project
- Inside that project: Create a new package
- Inside that package: Create a new Java class
Eclipse will help you a lot with the settings. Then just copy your code into that class and hit the 'start' button.
Solution 3:
by removing module class problem solved for me in eclipse