How to Install Apache Maven on Debian 11 Bullseye

Apache Maven is an open-source tool that allows the building automation of your java projects. It can also be used for projects in C#, Ruby, etc. Its most famous usage would likely involve Java development! The maven project comes from the Apache Software Foundation, where they were previously part of the Jakarta Project before moving on their own.

In the following tutorial, you will learn how to install Apache Maven on Debian 11 Bullseye using the command line terminal with two optional installation ways.

Update Debian

Before you begin, make sure your Debian system is up-to-date using the following command.

sudo apt update && sudo apt upgrade -y

Option 1. Install Apache Maven – APT Manager

Debian features Apache Maven in its default repository, making the installation straightforward. Still, the Debian repository version is often lagging behind the latest, so maybe not be as desirable as downloading the latest archive and installing manually.

Use the following command to begin the installation.

sudo apt install maven -y

Confirm the installation and the version installed on your system using the following version command.

mvn -version

Example output:

Install Apache Maven on Debian 11 Bullseye

For users who prefer using the latest version of Maven, if the Debian repository version is out of date for your needs, or if you need the newer version for better features, look to the next section.

Option 2. Install Apache Maven – Manually

The second option is to download and install the latest version manually, which can be better suited for more experienced users.

Install Java

First, before you install Apache, you must install Java on Debian using the following command.

sudo apt install default-jdk -y

Download & Setup

Next, use the wget command to download the archive. To find the latest version, visit here.



Next, extract the archive folder to the /opt/ directory.

sudo tar xzf apache-maven-3.8.4-bin.tar.gz -C /opt/

Now, navigate to the directory.

cd /opt/

Given that you have extracted the directory to the /opt/ location, you can either rename the folder or symlink it. Often, the symlink is the recommended method.

sudo ln -s apache-maven-3.8.4 maven

Install Apache Maven Environment

The environment variables need to be set, and this can be done by creating under the /etc/profile.d/ directory.

sudo nano /etc/profile.d/

Next, add the following to the file.

export M2_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

Save the file and then exit by pressing CTRL+O, then CTRL+X.

The last task is now to enable the environment with the following command.

source /etc/profile.d/

Confirm the installation by running the following command.

mvn -version

Example output:

Install Apache Maven on Debian 11 Bullseye

Comments and Conclusion

In the tutorial, you have learned two methods to install Apache Maven on Debian 11 Bullseye.

Overall, Maven is a great build tool that automates the whole process of building your project as per your requirements. It makes it easy for you to start your project in different environments without handling dependencies injection, builds or processing, etc., by adding new dependencies with some lines of commands only.


Like to get automatic updates? Follow us on one of our social media accounts!