I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

How to Install Apache Maven on Ubuntu 22.04

Hello, friends. In this post, you will learn how to install Apache Maven on Ubuntu 22.04 This post, is quite short, but it is useful for users who are just starting with Java.


Apache Maven is a project management software, and we can say that it is also a Java dependency manager. It is based on the POM concept, where all project management rules are defined.

Maven simplifies the tasks of compiling and building software applications, mainly used with programming languages that are intended to run on the Java Virtual Machine (JVM).

So let’s get started.

Install Apache Maven on Ubuntu 22.04

Maven is a very popular tool on Linux, so we can install it in several ways and methods.

1.- Install Maven using the official repositories

Apache Maven is included in the official repositories of Ubuntu 22.04. So to install it, we just have to open a terminal or SSH connection and update the entire system.

sudo apt update
sudo apt upgrade

Then, install Maven with this command:

sudo apt install maven

To check the installed version, you can run this command:

mvn --version

2.- Install Maven manually

The previous method is easy to use, but it does not provide us with the latest stable version of the tool. But no problem because we can download and install Maven manually.

First, download the binary of the latest stable version from the project website using wget.

1.- Download Apache Maven on Ubuntu 22.04
1.- Download Apache Maven on Ubuntu 22.04

At the time of writing this post, the latest stable version of Maven is 3.8.6.

Now, unzip it:

tar fxz apache-maven-3.8.6-bin.tar.gz

Then, move it to a system directory such as /opt.

sudo mv apache-maven-3.8.6 /opt/maven 

Now we need to define the correct environment variables for Maven

sudo nano /etc/profile.d/

And add the following content:

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

Apply changes

source /etc/profile.d/

Finally, check the installed version:

mvn --vesion
2.- Maven on Ubuntu 22.04
2.- Maven on Ubuntu 22.04



You have successfully finished this tutorial, where you learned how to install Maven without too many issues.


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook