How to install Apache Maven on ubuntu 16.04


Apache Maven is a build tool use for Java project, Developed by Apache Software Foundation, Written in Java, To get more information click here official website.

Install Dependencies

To install Apache Maven, You need to install first java with root privileges.

sudo -i
apt-get update -y
apt-get install default-jdk -y

Check Java Version

java -version

Download Apache Maven

To download the Apache Maven, You need to use the following commands.

cd /tmp

wget http://apachemirror.wuchna.com/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz

Extract Apache Maven

mkdir /opt/maven

tar xzvf apache-maven-3.6.3-bin.tar.gz -C /opt/maven –strip-components=1

Get Java Home

Use the given commands for Java home.

update-java-alternatives -l

You should get output like this.

/usr/lib/jvm/java-8-oracle

Environment for Apache Maven.

You need to create file on given path with required parameter.

vim /etc/profile.d/maven.sh

paste the given param.

export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

Update the permission of Apache Maven

source /etc/profile.d/mavenenv.sh
chmod +x /etc/profile.d/mavenenv.sh

Check Version

mvn –version

Install Apache Maven using apt-get on ubuntu 16.04 /18.04

Install Dependencies

To install Apache Maven, You need to install first java with root privileges.

sudo -i
apt-get update
apt-get install default-jdk -y

Check Java Version

java -version

Verify the Maven version by following the commands. 

apt-cache show maven | grep Version

You should get output like this.

Version: 3.3.9-3

Install Apache Maven

To install Apache Maven by using following commands.

apt-get install maven -y

Check Version of Apache Maven

mvn –version

You should get output like this.

Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_232, vendor: Private Build
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: “linux”, version: “4.13.0-36-generic”, arch: “amd64”, family: “unix”

How to install Apache Maven on ubuntu 16.04

Leave a Reply

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

Scroll to top