Thursday, February 27, 2014

Fixing java.lang.NoClassDefFoundError: org/codehaus/classworlds/Launcher

I came across this error after I installed a new version of maven.
$ mvn -version
java.lang.NoClassDefFoundError: org/codehaus/classworlds/Launcher
Caused by: java.lang.ClassNotFoundException: org.codehaus.classworlds.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:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.codehaus.classworlds.Launcher.  Program will exit.
Exception in thread "main"
The issue was with having two MAVEN_HOME locations (two versions) in the "path" variable. Once I removed a one, the issue resolved.
$ mvn -version
Apache Maven 3.1.1

No comments: