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
MAVEN_HOME is used for maven 1 and M2_HOMEis 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,
@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
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.
Based on problems in using M2_HOME related to different Maven versions installed and to simplify things, the usage of M2_HOME has been removed and is not supported any more MNG-5823, MNG-5836, MNG-5607
So now the mvn.cmd look like,
@REM -----------------------------------------------------------------------------
@REM Apache Maven Startup Script
@REM
@REM Environment Variable Prerequisites
@REM
@REM JAVA_HOME Must point at your Java Development Kit installation.
@REM MAVEN_BATCH_ECHO (Optional) Set to 'on' to enable the echoing of the batch commands.
@REM MAVEN_BATCH_PAUSE (Optional) set to 'on' to wait for a key stroke before ending.
@REM MAVEN_OPTS (Optional) Java runtime options used when Maven is executed.
@REM MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files.
@REM -----------------------------------------------------------------------------
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
On Windows, the current way to locate settings.xml is to go to %USERPROFILE%. There, a directory .m2 is contained, where one finds settings.xml.
Never use M2_HOME. It is unsupported since Apache Maven 3.5.0:
Based on problems in using M2_HOME related to different Maven versions installed and to simplify things, the usage of M2_HOME has been removed and is not supported any more MNG-5823, MNG-5836, MNG-5607.
Important change for windows users: The usage of %HOME% has been replaced with %USERPROFILE%MNG-6001