Reputation: 24248
I have created simple project with class Main and public static void main and System.out.println("Hello world"); And after have configured as maven project. After this main doesn't work:
java.lang.NoClassDefFoundError: main/Main
Caused by: java.lang.ClassNotFoundException: main.Main
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"
Why this happens? How to fix? Thanks.
Upvotes: 0
Views: 157
Reputation: 8534
Why don't you try creating a simple project using an archetype, and then compare the differences.
Suggest you choose the archetype maven-archetype-simple
mvn archetype:generate -D archetypeGroupId=org.apache.maven.archetypes -D maven-archetype-simple -D groupId=com.mycompany.mygroup -D artifactId=myapp
The import it to eclipse using prefererably the m2eclipse plugin or mvn eclipse:eclipse
to generate the eclipse .project files etc.
Upvotes: 1