Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between M2_HOME and MAVEN_HOME

I have two version of environment variables for maven home - M2_HOME and MAVEN_HOME.

Which one needs to be set?

like image 515
developer Avatar asked Jun 16 '13 18:06

developer


People also ask

What is MAVEN_OPTS =- Xms256m?

MAVEN_OPTS environment variable:This variable contains parameters used to start up the JVM running Maven and can be used to supply additional options to it. E.g. JVM memory settings could be defined with the value -Xms256m -Xmx512m .

What should be the environment variable M2_HOME be set to?

Set M2_HOME & PATH Create 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.

What is Maven home PATH?

Maven home: C:\Program Files\Apache Software Foundation\apache-maven-3.8.4. Java version: 11.0.11, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk11.0.11\ Default locale: en_IN, platform encoding: Cp1252.

How do I set environment variables in Maven Mac?

2.2) Setting Maven Environment Variables - M2_HOME and Path We have to add the Maven bin directory to the Path variable. Open . bash_profile in your favorite text editor and add below lines to the end of it. You can relaunch Terminal to load these profile settings or use source .


2 Answers

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.0 neither of these environment variables should be specified. Instead, the path should be updated to include the mvn executable.

like image 128
prunge Avatar answered Sep 21 '22 08:09

prunge


And, ironically, you must still use M2_HOME and M2 for Maven version 3. Otherwise, it fails, because they didn't follow this logical approach with Maven V3.x for some bizarre reason.

Consequently, it is not easy to support Maven 2 & Maven 3 on the same machine without rewriting your configuration.

like image 43
Martin Spamer Avatar answered Sep 20 '22 08:09

Martin Spamer