Share your love
Install Apache Maven on Ubuntu 20.04 with Easy Steps

In this tutorial, we want to teach you to Install Apache Maven on Ubuntu 20.04. Apache Maven is a cornerstone of Java development and the most used build management tool for Java. Maven’s streamlined, XML-based configuration model enables developers to rapidly describe or grasp the outlines of any Java-based project, which makes starting and sharing new projects a snap.
Maven also supports test-driven development and long-term project maintenance, and its declarative configuration and wide range of plugins make it a popular option for CI/CD.
You can now proceed to the following steps on the Orcacore website to set up Maven Ubuntu 20.04.
Table of Contents
Steps To Install Apache Maven on Ubuntu 20.04
To install Apache Maven Ubuntu 20.04, you must log in to your server as a non-root user with sudo privileges. To do this, follow our guide on the Initial Server Setup with Ubuntu 20.04.
Now follow the steps below to install the latest release of Maven on Ubuntu 20.04.
1. Install OpenJDK on Ubuntu 20.04
To set up Apache Maven, you need to have Java installed on your server. The default version of Java available in Ubuntu 20.04 is OpeJDK-11 which is compatible with Apache Maven’s latest version.
First, update your local package index with the command below:
sudo apt update
Then, run the following command to install the OpenJDK:
sudo apt install default-jdk -y
Verify your Java installation by checking its version:
java --version

2. Install Apache Maven LTS on Ubuntu 22.04
At this point, you need to visit the Apache Maven Downloads page and get the latest version available there by using the wget command.
sudo wget https://dlcdn.apache.org/maven/maven-3/3.9.0/binaries/apache-maven-3.9.0-bin.tar.gz
When your download is completed, extract your downloaded file with the following command:
tar -xvf apache-maven-*-bin.tar.gz
Then, move your extracted file to the /usr/share directory with the command below:
sudo mv apache-maven-3.9.0 /usr/share/maven
To use the maven command tool from anywhere in your terminal, you need to add its folder path in your bash profile. You can use the commands below:
# echo 'export PATH="$PATH:/usr/share/maven"' >> ~/.bashrc
# echo 'export PATH="$PATH:/usr/share/maven/bin"' >> ~/.bashrc
At this point, you need to source your bash profile:
source ~/.bashrc
Check your Maven installation on Ubuntu 20.04 by checking the MVN version:
mvn -v

3. Remove Apache Maven From Ubuntu 20
If you no longer want to use Maven, use the command below to uninstall it from Ubuntu 20.04:
sudo rm /usr/share/maven
To remove Java, you can use:
sudo apt autoremove default-jdk --purge
Conclusion
At this point, you learn to Install Apache Maven on Ubuntu 20.04. Apache Maven simplifies the build process, handles dependencies, and ensures consistency across software development teams by defining project structures, build configurations, and lifecycle tasks.
Hope you enjoy it. You may also like these articles:
How To Install OpenSSL 3 on Ubuntu 20.04
Install and Configure Jekyll on Ubuntu 20.04
Apache Cassandra Setup Ubuntu 20.04
Installing Yarn on Ubuntu 20.04