Dec 02, 2025
Edward S. & Ignas R.
3min Read
Software development is one of the most challenging areas to work in. Fortunately, the right tools can make the development process more streamlined and efficient.
Apache Maven is a build automation tool mostly used for Java projects. It focuses on the simplification and standardization of the building process. One of Maven’s main aspects is providing a comprehensive, maintainable, and simple model for projects.
This tutorial will cover the two methods of installing Apache Maven on Ubuntu and how to set up an environment for it.
A Brief Overview of Installing Maven on Ubuntu:
| Required Knowledge | Basic Ubuntu server management, Java installation |
| Privileges Required | Root or sudo user privileges |
| Difficulty | Intermediate |
| Main Goal | Installing Apache Maven using APT and directly from the official website |
Apache Maven is a free and open-source project management tool based on the Project Object Model (POM). Maven contains XML files or pom.xml, which include configuration details and project dependencies. Maven automates building, publishing, and deploying stages. It lets you work and manage several projects simultaneously.
Here are the main benefits of Apache Maven:
Before installing Apache Maven, your system must meet the following requirements:
Users can install Apache Maven using the Advanced Package Tool (APT) or through the official Apache Maven website.
Let’s start with the APT method.
The official Ubuntu repositories contain Maven packages by default. Thus, the most convenient way to install Apache Maven is by using the APT package manager.
However, the Maven package version in Ubuntu repositories may differ from the official one. It may also not be the latest release.
sudo apt-get update
sudo apt install default-jdk
java -version
sudo apt-get -y install maven
The default Maven installation directories are /usr/share/maven and /etc/maven. Verify the Apache Maven version using the following command:
mvn -version
If you see a similar window, you’ve successfully installed Apache Maven on your machine.
The second method is to install Maven from the official Apache website.
Java Installation
sudo apt-get update sudo apt install default-jdk
The installation might take a few minutes to complete.
java -version
The terminal will display the installed Java version.
Download Apache Maven
wget https://dlcdn.apache.org/maven/maven-3/3.8.7/binaries/apache-maven-3.8.7-bin.tar.gz -P /tmp
sudo tar xf /tmp/apache-maven-*.tar.gz -C /opt
sudo nano /etc/profile.d/maven.sh
export JAVA_HOME=/usr/lib/jvm/default-java
export M3_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M3_HOME}/bin:${PATH}sudo chmod +x /etc/profile.d/maven.sh
source /etc/profile.d/maven.sh
mvn -version

Apache Maven is a great tool to improve project management and make the development process much smoother.
In this tutorial, we’ve covered two methods to install Maven on Ubuntu and showed you how to set up environment variables for it.
We hope that you found this tutorial useful. If you have any questions or insights, leave them in the comments below.
How to List Packages in Ubuntu
How to Change Timezone in Ubuntu
How to List Users in Ubuntu
How to Install Python Pip on an Ubuntu System
How to Change Hostname in Linux
How to Install Java on Ubuntu
How to Install Jenkins on Ubuntu
How to Install Node on Ubuntu