Install Maven on Ubuntu

Download and Install Maven on Ubuntu

First need to make sure java is install already

1
java -version

Download maven binary using wget

1
wget http://mirror.reverse.net/pub/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz -P /tmp

extract to /opt folder

1
sudo tar xf /tmp/apache-maven-*.tar.gz -C /opt

rename the folder

1
2
cd /opt
mv apache-maven-* apache-maven

set environment variable(can be in ~/.bashrc file). Maven Home directory is /opt/apache-maven.

1
2
3
export M3_HOME=/opt/apache-maven
export MAVEN_HOME=/opt/apache-maven
export PATH=${MAVEN_HOME}/bin:${PATH}

Check maven version

1
2
3
4
5
6
$ mvn -version
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T15:00:29-04:00)
Maven home: /opt/apache-maven
Java version: 11.0.3, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.0.0-20-generic", arch: "amd64", family: "unix"

The global level configuration file is located at

  • /opt/apache-maven/conf/settings.xml

The user level configuration file is located at

  • ~/.m2/settings.xml