user710818
user710818

Reputation: 24248

Eclipse configure project as Maven problem

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

Answers (2)

crowne
crowne

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

user810430
user810430

Reputation: 11489

maven clear project settings and also source folder.

Upvotes: 1

Related Questions