Published February 12, 2018 by

Install Apache Maven on Linux (CentOS/RedHat/Debian)

Apache Maven is a software project management and comprehension tool. Maven can manage a project’s build, reporting, and documentation from a central piece of information. 

In this tutorial, we will learn to install Apache Maven on Linux systems.

Install JAVA

First, install java according to your Linux distribution

Install Java for Debian/Ubuntu based system

Install Java for CentOS/RedHat based system

Install Apache Maven

After installing Java on your system. Download Apache maven using the following command


# cd /usr/local
# wget http://www-eu.apache.org/dist/maven/maven-3/3.5.4/source/apache-maven-3.5.4-src.tar.gz


Extract the downloaded package

# sudo tar xzf apache-maven-3.5.4-src.tar.gz

Create a symbolic link to the maven executable

# sudo ln -s apache-maven-3.5.4  maven

Remove the downloaded archive file

# rm -f /usr/local/apache-maven-3.5.4-src.tar.gz

Setup Maven Environment Variables

Now set the environments variables by creating new file /etc/profile.d/maven.sh

# sudo vim /etc/profile.d/maven.sh

add following content in to the file.

export M2_HOME=/usr/local/maven
export PATH=${M2_HOME}/bin:${PATH}

Now load the environment variables in the current shell using the following command.

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

Check Maven Version

That’s it, Maven is installed and Use the following command to check the version of Maven. 

# mvn -version