This question already has an answer here:
I am having difficulties installing Maven.
I have set all the enviromental variables according to this: http://maven.apache.org/download.html
Although I am using windows 7, when I try and run the command mvn --version
, I get, mvn is not recognized as an internal or external command
etc.
When I run it from within src\bin
, I get the error:
Exception in thread "main" java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher
at java.net.URLClassLoader$1.run<URLClassLoader.java:202>
at java.security.AccessController.doPrivleged(Native Method)
...etc
then:
Could not find the main class: org.codehaus.plexus.classworlds.launcher.Launcher.
Do you have maven 2 also installed? I found one link in searching, see if it helps http://blogs.oracle.com/sreekanth/entry/java_lang_noclassdeffounderror_org_codehaus
and also double check your environment variables to make sure you have set all the variables mentioned in the doc.
For this error "mvn is not recognized as an internal or external command", add src/bin folder in 'path' environment variable.
Check that you don't have an M2_HOME environment variable.
I setup
M2_HOME
like this:and saw the same exception:
I changed to use absolute path and it worked:
In my case, the M2_HOME env variable wasn't the problem. I think that java and/or mvn startup script doesn't expand the tilde in classpath cmd line args.
"mvn is not recognized as an internal or external command etc." means you haven't set your environment variable in windows. Read the whole http://maven.apache.org/download.html :-)
All you should need to do to install and use maven:
1) Download maven 3. The ZIP should be fine. Install it in a known place; I use c:\tools\ as the parent directory but your mileage may vary.
2) Set your PATH to point to the bin directory in the installation directory. If Maven is in c:\tools\maven-3.0.3 (as it is on my system), you'd add c:\tools\maven-3.0.3\bin to PATH:
You may also want to set MVN_HOME:
3) start a new command shell (cmd.exe). mvn should work; if not, you've skipped something here or something's badly wrong in your configuration.
blanking out M2_HOME worked for me on Ubuntu. Can test with just: 'export M2_HOME='