Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) Could not find the main class: org.codehaus.plexus.classworlds.launcher.Launcher. Program will exit.My use case was that I had installed maven3 and afterwards tried to use maven2. All the environment variables updates have been setup in:
~/.bashrcHowever once trying to use maven2 exception appeared (Even in the new terminal session).
Solution was found based on advice present in: http://cyntech.wordpress.com/2011/03/09/maven-2-error/
Running command:
which mvnrevealed the problem, as I still had in my $PATH the maven3 binary. Even if I appended the maven2, it was there on the later position => maven3 was to be used, but with changed $M2_HOME (reffering to maven 2).
Fixing the $PATH did the job for me.
This might not be your case, therefor as a general sum up of possible root causes, I recommend checking: http://stackoverflow.com/questions/6198677/java-lang-noclassdeffounderror-org-codehaus-plexus-classworlds-launcher-launche