What's the correct Maven environment variable name: MAVEN_HOME
, MVN_HOME
or M2_HOME
?
I've found some details about MAVEN_HOME
and M2_HOME
here. But I also have seen MVN_HOME
around.
What's the correct Maven environment variable name: MAVEN_HOME
, MVN_HOME
or M2_HOME
?
I've found some details about MAVEN_HOME
and M2_HOME
here. But I also have seen MVN_HOME
around.
Here is my Maven setup. You can use it as an example. You don't need anything else in order to use Maven.
M2_HOME is used for both Maven 2 and 3
I've personally never found it useful to set
M2_HOME
.What counts is your $PATH environment. Hijacking part of the answer from Danix, all you need is:
The
mvn
script computesM2_HOME
for you anyway for what it's worth.$M2_HOME
is used sometimes, for example, to installTakari Extensions for Apache Maven
One way to find
$M2_HOME
value is to search formvn
:And, probably it will be:
/opt/maven/
M2_HOME
(or any other) is not to be used as of Maven 3.5.0. See MNG-5607 and Release Notes for details.MAVEN_HOME is used for maven 1 and M2_HOME is used to locate maven 2. Having the two different _HOME variables means it is possible to run both on the same machine. And if you check old mvn.cmd scripts they have something like,
See that
@REM M2_HOME - location of maven2's installed home dir
Anyway usage of this pattern is now deprecated with maven 3.5 as per the documentation.
So now the mvn.cmd look like,
So what you need is JAVA_HOME to be set correctly. As per the new installation guide (as of 12/29/2017), Just add the maven bin directory path to the PATH variable. It should do the trick.
ex :
export PATH=/opt/apache-maven-3.5.2/bin:$PATH
We have M2_HOME,MAVEN_HOME,M3_HOME all are available in market
Previously M2_HOME is the only environment variable used by all as a standard.
But,due latest releases the MAVEN_Home came as standard but some old tools are still trying to find only M2_HOME
so we should have both M2_HOME,MAVEN_HOME to sustain with old and new tools.
M2_HOME can be used for both as well