I've tried installing Maven to Windows 7 with poor results. Some basic info:
Maven installation directory: C:\Program Files\Apache Software Foundation\apache-maven-3.0.4
System Variable "M2_HOME
": C:\Program Files\Apache Software Foundation\apache-maven-3.0.4\
System Variable "Path
" : %M2_HOME%apache-maven\src\bin;%JAVA_HOME%\bin
If I run mvn --version
in the command path, I get the error message:
Please set the
M2_HOME
variable in your environment to match the location of the Maven installation
So at the moment the subdirectory for mvn
is not set according to the instructions, which would be %M2_HOME%\bin
. If I replace %M2_HOME%apache-maven\src\bin
with that one, I get:
mvn is not recognized as an internal or external command, operable program or batch file
In the Maven installation directory (or in the zip-file) there is no \bin
folder directly in apache-maven-3.0.4
and I wonder if there should be one?
I'm a complete novice to Maven, hopefully you guys can help.
By the way the Java command works from any directory, so I don't think that's the issue here, but I can't be sure.
Set M2_HOME & PATHCreate an environment variable named M2_HOME which refers to directory where maven was untarred/ unzipped. and then add this variable to PATH environment variable. $>export PATH=$M2_HOME/bin:$PATH. Click OK, then Edit the 'Path' user variable to add M2_HOME\bin folder in it.
The M2_HOME is equivalent to JAVA_HOME and should point to the installation directory of Maven.
MAVEN_HOME is for Maven 1, M2_HOME is for Maven 2 and later. Maven 2 was a complete rewrite from Maven 1 and was not backwards compatible. Having the two different _HOME variables means it is possible to run both on the same machine. UPDATE. As of maven 3.5.
The home paths ( JAVA_HOME , M2_HOME ) are not mandatory but good to have. One of the advantages is: It helps you make changes at one place rather than search you way in the PATH variable when you install next version of Java or Maven.
In M2_HOME
- set C:\apache-maven-3.0.4
i.e. path without bin
.
In PATH
- set %M2_HOME%\bin
i.e. with bin
in path.
If your downloaded package apache-maven-3.3.9 does not contain a bin folder your download is wrong. you have to download a zip file which contains bin, boot, conf, lib folder otherwise there has gone something wrong. The downloaded file should have about 4.8 mb size. You can check the file via md5 or SHA1 checksums.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With