Reading Time: 3 minutes

What is Apache Maven?

Apache Maven is one of the most popular build management tools for Java projects. It employs a Project Object Model or POM utilizing an XML file to define the structure of a project, including its dependencies, documentation, and build parameters. Instead of having to manage those things individually, Maven consolidates that functionality allowing for a more streamlined and efficient project management process. In this tutorial, we are going to cover how to install Maven on Ubuntu 18.04.

How to Install and Configure Apache Maven on Ubuntu 18.04

Preflight Check

This tutorial was performed on a Liquid Web Ubuntu 18.04 LTS Virtual Private server as the root user.

Install Via Apt

The default Ubuntu package repository includes a package for Maven, and that is the simplest way to get the package installed.

Step #1: Update Packages

First, as a best practice, update system packages before getting started by running the following command:

root@ubuntu:~# apt update -y

Step #2: Install Maven

Next, use Apt to install maven by running:

root@ubuntu:~# apt install maven -y

That’s it! Maven is installed. To verify this, run the following command to check the version of Maven on the system:

root@ubuntu:~# mvn -v
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-91-generic", arch: "amd64", family: "unix"

Install Maven via Download

It is possible that the packaged version of Maven provided by the Ubuntu repository is not the most up-to-date version. To obtain the most up-to-date version of Maven, it can be installed after being downloaded from the Apache Maven website.

Step #1: Download Maven

Download Maven into the /tmp directory utilizing the following command:

wget -P /tmp

As of the writing of this article version, 3.6.3 is the latest version of Maven. To check if there is a newer version, visit the Maven download page.

Next, extract the newly downloaded Maven archive to the /opt directory:

root@ubuntu:~# tar xf /tmp/apache-maven-3.6.3-bin.tar.gz -C /opt

To make it more straightforward to upgrade in the future, create a symlink to the Maven installation directory:

root@ubuntu:~# ln -s /opt/apache-maven-3.6.3 /opt/maven

In the future, to upgrade Maven, download the newer version, extract it, and point the symlink to the new version.

Step #3: Configure Environment Variables

Create a file inside the /etc/profile.d/ directory:

root@ubuntu:~# vim /etc/profile.d/

Copy the following configuration out and paste it into the file:

export JAVA_HOME=/usr/lib/jvm/default-java
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

Finally, to get these variables into play in the environment, run the source command on the file:

root@ubuntu:~# source /etc/profile.d/

Step #4: Verify Maven Installation

To verify Maven is installed properly, run the version command and check the output:

root@ubuntu:~# mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /opt/maven
Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-91-generic", arch: "amd64", family: "unix"

That’s it! Maven is now installed. It’s now possible to use Maven to help make project management and definition simpler.


Apache Maven is one of the most utilized build management tools for Java projects in use today. It uses an XML file to define the structure of a Project Object Model, including its dependencies, documentation, and build parameters. It consolidates these functions into a single platform that is streamlined, and efficiently manages the development process.

We pride ourselves on being The Most Helpful Humans In Hosting™!

Our support staff is always available to assist with any issues related to this topic, 24 hours a day, 7 days a week 365 days a year.

We are available, via our ticketing systems at, by phone (at 800-580-4986) or via a LiveChat or whatever method you prefer. We work hard for you so you can relax.

Avatar for Justin Palmer

About the Author: Justin Palmer

Justin Palmer is a professional application developer with Liquid Web

Latest Articles

Controlling PHP settings with a custom php.ini file

Read Article

How to install Puppet Server on Linux (AlmaLinux)

Read Article

Email security best practices for using SPF, DKIM, and DMARC

Read Article

Linux dos2unix command syntax — removing hidden Windows characters from files

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article