How to Install Apache Maven on Ubuntu 20.04

Apache Maven is an advanced and exclusive tool used in the building of managing projects typically related to java. It is an open-source that utilizes the POM encompassing the XML file to retail the crucial project information, that culminates in the information regarding the arch project, its dependencies, and configuration files. To effectively install the apache maven on Ubuntu 20.04 you will need the basic knowledge over the working and commands of Linux, privileges of the root user, and the recognition of sudo commands. The tool is designed to assist its user in building projects by proficiently documenting and reporting the central project related information. Apache Maven qualifies as the best-suited tool for managing java projects. It has built-in objective commands to deal with the packages and code composition.

Installation process

Installing apache maven is a relatively short process composite on basic 4 steps. After undergoing these 4 steps you can avail all the benefiting features of apache Marven to ably manage the java projects on your Ubuntu.

  • Step# 1: Package Upgradation
  • Step# 2: Installation of Apache Maven
  • Step# 3: Setting-up environmental variables of apache maven.
  • Step# 4: Verification


It is necessary to have a java system installed in your server along with the development kit of java encompassing JDK, and JRE to run the command of maven. If you don’t have these systems installed, then implement this command.

$ sudo apt install default-jdk

You can verify the installation of the java system and its kit using.

$ java -version

Package up-gradation

Update the existing package using sudo apt command. It is fundamental to update your existing packages before installing any tool or server on the ubuntu to effectively run it.

$ sudo apt update

You can also run this command before installing the java kit, that way your system packages will be updated along with the installation of the kit.

Installation of apache maven

There are primarily two methods to install an apache maven in your system. you can either download it with the apt command or directly from its web source through the wget command.

$ sudo apt install maven

$ mvn -version

If you are inclined towards downloading it from the webserver to get the latest version of apache maven, then apply the wget command.

$ cd /usr/local

$ sudo wget https://www-eu.apache.org/dist/maven/maven-3/3.6.3/binaries/

Now extract the downloaded maven from the tmp directory to opt directory.

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

If you wish to have prominent control over maven then you can also generate a link symbolizing the maven directory by applying the following code.

$ sudo ln -s /opt/apache-maven-3.6.3 /opt/maven

For simply extracting the downloaded maven without changing its directory use the following commands

$ sudo tar xzf apache-maven-3.6.3-bin.tar.gz

$ sudo ln -s apache-maven-3.6.3 maven

Setting-up environmental variables of apache maven

To set the environmental variables of apache maven you will be required to create a file for those variables. Implement the following commands to generate a new file.

$ sudo vi /etc/profile.d/maven.sh

Now to set up variables in that file apply.

$ source /etc/profile.d/maven.sh


To simply verify the installation of Apache on your Ubuntu 20.04 apply mvn command as follows:

$ mvn -version

And lastly, clean up your disk for nifty performance by clearing the archives where you downloaded the maven.

$ sudo rm -f apache-maven-3.6.3-bin.tar.gz


Installing apache maven on Ubuntu 20.04 is feasible and doesn’t need lengthy and complex commands. If you already have a java kit installed in your system, then the installation process will become more platen and convenient. Following the above-mentioned step-by-step process for installation, you won’t face any complex errors. If you are installing some other latest version rather than 3.6.3 of the apache Maven then apply the commands that involve the description of the version carefully.

About the author

Younis Said

Younis Said

I am a freelancing software project developer, a software engineering graduate and a content writer. I love working with Linux and open-source software.