How to install Apache Maven 3.6.1 on Linux Debian 9?

How to install Apache Maven 3.6.1 on Linux Debian 9?

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information. It is a build automation tool and it is used by almost all Java projects. It automatically downloads the libraries and dependencies from the Maven repositories and store it into local machine cache. – by maven.apache.org

PREREQUISITES

  1. JDK

DOWNLOAD

We can download the latest version of Apache Maven from the Maven official site. The Official site link has been given below.

https://maven.apache.org/download.cgi

change directory

Execute the following command to change the directory into “/usr/local” in your Linux Debian machine.

cd /usr/local 

wget

By using wget command we can download the latest Apache maven from the Maven official site. Execute the below command to download the maven.

sudowget http://www-eu.apache.org/dist/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz 

extract the file

By using below commands to extract the downloaded Maven file.

sudo tar xzf apache-maven-3.6.1-bin.tar.gz
sudo ln -s apache-maven-3.6.1 apache-maven 

set environment variable

Use the below command to set the environment variable by using vi editor.

sudo vi /etc/profile.d/apache-maven.sh

Add the following lines to set the environment path for maven.

export MAVEN_DOWNLOAD_PATH=/usr/local/apache-maven
export PATH=${MAVEN_DOWNLOAD_PATH}/bin:${PATH}

LOAD THE ENVIRONMENT PATH

To load the environment path, execute the below source command.

source /etc/profile.d/apache-maven.sh 

M2_HOME

The mvn script computes M2_HOME automatically. No need to set the M2_HOME environment path. Refer the below stackoverflow.com link to see the answer.

https://stackoverflow.com/questions/26609922/maven-home-mvn-home-or-m2-home

check maven version

Execute the following command to check the Maven version.

mvn -version
mvn version

Apache Maven 3.6.1 has been installed successfully on Linux Debian 9.

Advertisements