Installing Apache Maven on ubuntu 18.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.

Step 1: Installing Dependencies

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

To take root login.

sudo -i

To update default repository

apt-get update

To install Java 8

apt-get install default-jdk -y

Step 2: Verify JAVA Version

We need to execute the given command to know installed JAVA Version on ubuntu 18.04 LTS.

java -version

Step 3: Download Maven

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

To move in /tmp

cd /tmp

To download the maven.


Step 4: Extracting Apache Maven

To make maven directory inside /opt.

mkdir /opt/maven

To extract.

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

Step 5: Get JAVA HOME

Use the given commands for Java home.

update-java-alternatives -l

You should get output like this.


Step 6: Environment for Apache Maven

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

vim /etc/profile.d/

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/
chmod +x /etc/profile.d/

Step 7: Check Maven Version

We need to execute the given command for the same.

mvn –version


That’s it! You have successfully installed Apache Maven Ubuntu 18.04 LTS. Still you are having any issue, Feel free and leave a comment below.

Installing Apache Maven on ubuntu 18.04

Leave a Reply

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

Scroll to top