How To Install Apache Maven on Ubuntu 16.04 and 14.04

How To Install Apache Maven on Ubuntu 16.04 and 14.04

How To Install Apache Maven on Ubuntu 16.04 and 14.04 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. This tutorial will help you to install Apache Maven on your Ubuntu 17.04, 16.10, 16.04 LTS, 14.04 LTS, and Ubuntu 12.04 LTS systems.

Step 1. Install Java

First of all, you make sure that you installed appropriate Java on your system.Java is the primary requirement of installing Apache Maven on nix systems. 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)

If you don’t have Java Development Kit installed on your system. Visit install Java 8 on Ubuntu

Step 2. Install Apache Maven on Ubuntu

After verifying java version on your system. Download Apache maven from its official website or use following command to download Apache Maven 3.3.9.

$ cd /usr/local
$ wget

Now extract downloaded archive using following command.

$ sudo tar xzf apache-maven-3.3.9-bin.tar.gz
$ sudo ln -s apache-maven-3.3.9 apache-maven

Step 3. 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/

$ sudo vi /etc/profile.d/

and add following content.

export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export M2_HOME=/usr/local/apache-maven
export MAVEN_HOME=/usr/local/apache-maven
export PATH=${M2_HOME}/bin:${PATH}

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

$ source /etc/profile.d/

Step 4. Verify Installation

Finally, You have successfully installed and configured Apache Maven on your Ubuntu system. Use the following command to 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.

Was this Tutorial helpful? Help others share on Facebook, Twitter, and Google Plus!

Enjoyed this video?
How To Install Apache Maven on Ubuntu 16.04 and 14.04
"No Thanks. Please Close This Box!"