How to install Maven on Unix-based Operating Systems (Linux, Solaris and Mac OS X)

By: Slav Kurochkin

It seems that old installation settings for maven gone, here is recap for UNIX-based operating systems.

First lets check if you have Maven installed on your computer, basically open your terminal and run: mvn -v, if you are not getting
any result or you something like: "command not found", most likely Maven is not installed on your computer.

First thing you would need to is download maven zip file.

Then make sure if installation settings been updated on apache website, if no, then follow the instructions bellow:

Unix-based Operating Systems (Linux, Solaris and Mac OS X)

1. Extract the distribution archive, i.e. apache-maven-3.2.2-bin.tar.gz to the directory you wish to install Maven 3.2.2. These instructions assume you chose /usr/local/apache-maven. The subdirectory apache-maven-3.2.2 will be created from the archive.

2. In a command terminal, add the M2_HOME environment variable, e.g. export M2_HOME=/usr/local/apache-maven/apache-maven-3.2.2.

3. Add the M2 environment variable, e.g. export M2=$M2_HOME/bin.

4. Optional: Add the MAVEN_OPTS environment variable to specify JVM properties, e.g. export
MAVEN_OPTS="-Xms256m -Xmx512m". This environment variable can be used to supply extra options to Maven.

5. Add M2 environment variable to your path, e.g. export PATH=$M2:$PATH.

6. Make sure that JAVA_HOME is set to the location of your JDK, e.g. export
and that $JAVA_HOME/bin is in your PATH environment

Note: well, simply run $JAVA_HOME and see if there is output, in my case JAVA_HOME been set to: /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre

7. Run mvn --version (or mvn -v) to verify that it is correctly installed.

View Comments

Leave a Comment

Use markdown or basic HTML and be nice.