[How To] Install Apache Maven in Linux, Solaris and Mac OS X

The Apache Maven tool is used to build Java projects. It is very important to set Maven environment variables in order to execute the Maven commands.

This post will explain how to set Maven environment variables in Linux.

1) Download Apache Maven binary archive under /opt partition from here

1
2
cd /opt
wget http://mirror.olnevhost.net/pub/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz

2) Extract the archive

1
tar -xzvf apache-maven-3.0.5-bin.tar.gz

3) Go to the extracted directory

1
cd apache-maven-3.0.5

4) Get current working directory

1
pwd

Output:

/opt/apache-maven-3.0.5

5) Set the Apache Maven environment variables for the current user

1
2
export M2_HOME=/opt/apache-maven-3.0.5
export PATH=${M2_HOME}/bin:${PATH}

To set the environment variables on server boot and for all the users, update either each user's bash_profile file or /etc/rc.local file.

6) Verify by running any maven command

1
mvn --version

Output:

Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 19:21:28+0530)
Maven home: /opt/apache-maven-3.0.5

Hope this helps! 🙂

Share on Facebook2
Share on Google+5Tweet about this on TwitterShare on StumbleUpon0Share on LinkedIn0Share on Tumblr0Digg thisPin on Pinterest2Share on Reddit0Email this to someonePrint this page
The Apache Maven tool is used to build Java projects. It is very important to set Maven environment variables in order to execute the Maven commands. This post will explain how to set Maven environment variables in Linux. 1) Download Apache Maven binary archive under /opt partition from here cd /opt wget http://mirror.olnevhost.net/pub/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz 2) Extract the archive tar -xzvf apache-maven-3.0.5-bin.tar.gz 3) Go to the extracted directory cd apache-maven-3.0.5 4) Get current working directory pwd Output: /opt/apache-maven-3.0.5 5) Set the Apache Maven environment variables for the current user export M2_HOME=/opt/apache-maven-3.0.5 export PATH=${M2_HOME}/bin:${PATH} To set the environment variables on server boot and for…

Review Overview

User Rating: 4.9 ( 2 votes)

About Abhijit Sandhan

Abhijit Sandhan
Loves Linux, Blogging, Traveling, Hiking and sharing knowledge!

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA