Set Maven Home on Ubuntu

January 22, 2016 by Sandeep Bhardwaj | Tags:


Setting the environment variable in Ubuntu in really easy, just need to edit the /etc/profile. Just add your maven installation directory as below.

Open the /etc/profile file in your favorite editor.

sudo gedit /etc/profile

Add following lines in end

M2_HOME=/data/dev/tools/apache-maven-3.3.9
PATH=$PATH:$M2_HOME/bin
export M2_HOME
export PATH

Verify the M2_HOME

echo $M2_HOME

Check the maven version

mvn -v

Output

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T22:11:47+05:30)
Maven home: /data/dev/tools/apache-maven-3.3.9
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: /usr/local/java/jdk1.8.0_60/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.19.0-47-generic", arch: "amd64", family: "unix"