Apache Maven is a project management software, managing building, reporting and documentation of a Java development project. imilar to how the make utility builds an executable from source code and libraries using a Makefile, Apache Ant builds a Java project from its source code and libraries by using a similar XML file.
This article will help you to install Apache Maven on your Ubuntu systems.
Step #1 Install Java
JAVA is the first requirement for Apache. Java is the primary requirement of installing Apache Maven. So firstly you need to install Java on your system also make sure you have installed JDK and JRE both.
$ java -version
java version "1.8.0_121"
ava(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode, sharing)
Step #2 Download Apache Maven
You can download the latest version from the download page also or you can use below link to download Apache Maven.
$ cd /opt
$ wget http://www-eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
Step #3 Extract Apache Maven
Now extract downloaded archive using following command.
$ sudo tar xzf apache-maven-3.3.9-bin.tar.gz
Step #4 Install Apache Maven on Ubuntu
After extracting the binary files we will create symbolic link to install the Apache Maven.
$ sudo ln -s /opt/apache-maven-3.3.9/bin/mvn /usr/bin/mvn
Step #5 Setup Environment Variables
As you have downloaded pre compiled Apache Maven files on your system. Now set the environments variables by creating new file /etc/profile.d/maven.sh.
$ sudo vi /etc/profile.d/apache-maven.sh
and add following content.
export PATH MAVEN_HOME
Now load the environment variables in current shell using following command.
$ source /etc/profile.d/apache-maven.sh
Step #6 Verify Installation
After successfully configured Apache Maven on Ubuntu system run the following command to verify the installation and check the version of Maven.
$ mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T22:11:47+05:30)
Maven home: /usr/local/apache-maven
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-21-generic", arch: "amd64", family: "unix"
To read more about Apache Maven visit here.