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!
You probably need to set MAVEN_HOME plus M2_HOME . Both with the same path . Make sure that the variables must be set so well and try again. After trying to install version 7.8 of java because Version 6 may not be compatible .
NB : set maven in path , for instance on my Mac I have a .profile with the following settings : export JAVA_HOME = $ ( Library / Java / JavaVirtualMachines / jdk1.8.0_101.jdk / Contents / Home ) export PATH = / Users / alessandropioardizio / Desktop / SDK / apache - maven - 3.1.1 / bin : $ PATH
Let me know if it works .
I resolved mine by upgrading my maven from apache-maven-3.3.9 to apache-maven-3.5.4. And finally, Modify my System variables to apache-maven-3.5.4: Add both M2_HOME
M2_HOME :: C:\apache-maven-3.5.4
JAVA_HOME : C:\Program Files\Java\jdk1.8.0_101
Is there a
C:\mvn.bat
?On Windows, the current folder is always in the
PATH
.[EDIT] The error can have several reasons: The version of
mvn.bat
doesn't fit the rest of the code, or the libraries are corrupt.To get one step further, change the line
@echo off
inmvn.bat
to@echo on
and run the script again. It will then print each command as it is executed. Search the output for%CLASSWORLDS_JAR%
Make sure all JARs mentioned in
%CLASSWORLDS_JAR%
exist and are OK.I had similar by having mvn.bat for maven2 in other part of PATH. So check carefully all directories of your PATH variable.
I resolved this problem by removing all JRE/JDK then reinstalling the needed JDK and removing all spaces from folders path.
Try this:
.bash_profile:
This work for my Mac(os x ver 10.11) when I use maven2 after maven3.