This article will show you how to install Maven on Ubuntu 16.04(Xenial Xerus). There are 3 approaches to install Maven on Ubuntu.

  • Install with apt-get
  • Install manually
  • Install with SDKMAN

We will try both approaches in this tutorial.

install maven on ubuntu 16-04

Maven

1. Install Maven on Ubuntu 16.04 with Apt-get

We will use apt-get to install Maven on Ubuntu 16.04. This is the simplest way.

1.1. Open terminal and run below command

1.2. Verification

We can verify whether Maven is installed successfully or not by type command:

The output will be similar to below:

Note that the output also show us the Maven’s home, which is: /usr/share/maven

2. Install Maven on Ubuntu 16.04 Manually

2.1. Download Maven

You can download Maven distribution from the Apache Maven website. Currently, the latest release of Maven is version 3.3.9.

In the following command, I will download the binary only version of Maven:

2.2. Unpack Maven

The above command will unpack the Maven distribution to /usr/local/apache-maven-3.3.9

Next, we will create a symbolic link to the Maven distribution:

2.3. Create MAVEN_HOME Environment Variables

Create a maven.sh file at /etc/profile.d folder (you can use vi with below command)

Enter the follow content to the file:

Save the file.

We will need to activate the above environment variables. We can do that by log out and log in again or simply run below command:

2.4. Verification

We can verify whether Maven is installed successfully or not by type command:

3. Install Maven on Ubuntu 16.04 With SDKMAN

SDKMAN is a tool for managing parallel versions of multiple Software Development Kits on most Unix based systems. We can leverage SDKMAN to install Maven on Ubuntu 16.04.

3.1. Install SDKMAN

3.1.1. Open terminal and enter

Then follow the instructions on-screen to complete installation.

Note that, SDKMAN may ask you to install unzip package as the following:

In that case, you simply need to install unzip by issuing command:

3.1.2. Enter the following code snippet on the terminal

3.1.3. Lastly, verify that installation succeeded

The output will be similar to:

3.2. Install Maven By SDKMAN

3.2.1. List versions of Maven currently supported by SDMMAN

Here is the sample output on my PC:

3.2.2. Install Maven 3.3.9 on mine

3.2.3.Verification

We can verify whether Maven is installed successfully or not by type command:

Sample output on my terminal:

Note that Maven’s home directory is:  /home/ubuntu/.sdkman/candidates/maven/current

4. Summary

We have just tried to install Maven on Ubuntu 16.04  LTS (Xenial Xerus). There are 3 installation approaches for you to select. Both of them are simple. However, the first and third ones seems to be more simple and be easier to switch between different version of Maven. If you’re looking for Gradle installation tutorial, you can refer to my recent post: Install Gradle on Ubuntu 16.04 LTS (Xenial Xerus)

 

 

0 0 vote
Article Rating