APACHE MAVEN ON UBUNTU 16.04

INSTALLATION OF APACHE MAVEN ON UBUNTU 16.04

Apache Maven is a free and open source management tool which is used for Java projects.It is centrally used for managing project build, Documentation and reporting.

It also provides a complete framework to automate project build’s Infrastructure.

Prerequisites

Java is the essential requirement for Apache Maven.We can either install Java Development Kit (JDK) or OpenJDK.

Installation of Openjdk

We can install Java OpenJDK directly using the below command.

apt-get update

apt-get install openjdk-8-jdk -y

Run the below command to verify the version of Java installed:

java -version

Output:

 

 

 

Installation of Apache Maven

Refer this link to get the latest version of Apache Maven from the official Website.

Else You can use the following command to download.

wget http://apache.claz.org/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz

Extract the downloaded file using tar command.

tar –xvzf apache-maven-3.5.2-bin.tar.gz

Then move the contents to /opt directory

mv apache-maven-3.5.2 /opt/maven

Setting Environment Variables

Now We need to set the environment variables by creating a file maven.sh under /etc/profile.d/ directory.

vi /etc/profile.d/maven.sh

Copy the below line of codes to the file

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

Now, We have to load the environment variables.

source /etc/profile.d/maven.sh

Check Maven Installation

We can check whether the Apache Maven has been successfully installed and configured on the system.

mvn -version

Output

 

 

 

 

That’s All.We have installed Apache Maven on Ubuntu 16.04.Hope you find it helpful.