Hamsa K
5 min read | 3 weeks ago

How to Install Apache Maven on Debian 10

Install Apache Maven on Debian 10

Maven is a build automation tool used primarily for Java projects. Maven can also be used to build and manage projects written in C#, Ruby, Scala, and other languages. The Maven project is hosted by the Apache Software Foundation, where it was formerly part of the Jakarta Project.This article guide you how to install Apache Maven on Debian 10.


The debian instance you have access to the root user or user with sudo privileges and run below commands to upgrade current packages to latest version.

sudo apt update

Step 1: Install Java

Apache Maven required Java to be installed on your system.Here i have installed java 11 and follow below commands to install it.

sudo apt install default-jdk

once java is installed, you can check version

java --version

sample output:

root@debian:~# java --version
openjdk 2020-11-04
OpenJDK Runtime Environment (build
OpenJDK 64-Bit Server VM (build, mixed mode, sharing)

Also Read -> How to Install php 8 on Debian 10

Step 2: Install maven

Download the Apache maven archive file from its official website or use following command to download.

cd /opt
wget https://downloads.apache.org/maven/maven-3/3.8.0/binaries/apache-maven-3.8.0-bin.tar.gz

once it is downloaded, extract it and rename as below

root@debian:/opt# tar -xvzf apache-maven-3.8.0-bin.tar.gz
root@debian:/opt# mv apache-maven-3.8.0 maven

Step 3: Setup Environment variables

Next we need to set up the environment variables by creating new file /etc/profile.d/maven.sh

sudo nano /etc/profile.d/maven.sh

add below contents to above file.

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

save and exit the file.

Note: you can get JAVA_HOME information from 'sudo update-java-alternatives -l' command.

Then, make the script executable using following command

sudo chmod +x /etc/profile.d/maven.sh

Now load the environment variables in current shell.

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

Step 4: Verify Maven

Once everything has been successfully configured, check the version of the Apache Maven as below.

mvn --version

sample output:

root@debian:~# mvn --version
Apache Maven 3.8.0 (6aa1f4acf5d6323e9aa08b763cb9933dc96749b9)
Maven home: /opt/maven
Java version:, vendor: Debian, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.19.0-14-amd64", arch: "amd64", family: "unix"

That's it.Now you have successfully installed and configured Apache maven on Debian 10 system.


Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy