Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New Maven install: mvn -version java.lang.ClassNotFoundException

Tags:

java

maven

So I've installed maven with the following details:

Install path:

C:\Program Files\Apache Software Foundation\apache-maven-3.0.3

Env vars:

JAVA_HOME C:\Progra~1\Java\jdk1.6.0_25
M2_HOME C:\Program Files\Apache Software Foundation\apache-maven-3.0.3

User vars:

M2 %M2_HOME%\bin
PATH %JAVA_HOME%\bin;%M2%;

Now, from the command line

C:\>javac -version
javac 1.6.0_25

C:\>mvn -version
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/plexus/c
lassworlds/launcher/Launcher

Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.lau
ncher.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.loadClss(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.plexus.classworlds.launcher.Launcher
.  Program will exit.

I've been insulated from the command line build details for Java thus far thanks to Eclipse, but it looks like it's having problems with finding the plexus-classworlds-2.4.jar in the /boot dir. Should I need some additional path info?

Thanks!

like image 623
jchristof Avatar asked Nov 15 '11 15:11

jchristof


2 Answers

I was able to resolve my issue with following when

export JAVA_HOME=/blah/blah
export M2_HOME=/usr/local/maven   
export M2=M2_HOME/bin

I was able to figure out looking at the folder name, it was 3.2.1

Perhaps, I didn't read document, but here's my answer to this problem.

export JAVA_HOME=/blah/blah
export M3_HOME=/usr/local/maven   
export M3=M2_HOME/bin

My java is 7. Hope this helps some people with Maven 3 instead of M2.

like image 135
Jerry H Avatar answered Oct 19 '22 23:10

Jerry H


I had similar by having mvn.bat for maven2 in other part of PATH. So check carefully all directories of your PATH variable.

like image 41
kan Avatar answered Oct 20 '22 00:10

kan