Howdy Folks. Let’s quickly check out installation process of Apache Maven on Ubuntu. There are multiple ways this can be done. If you want to check out installing Oracle Java on Ubuntu, check out this page.

1 Using Ubuntu Repositories

Well, if you using Ubuntu, it’s a quite straightforward to install it using the Ubuntu repositories. Fortunately, Ubuntu already ships with the repositories that contain the Maven packages.

For all those, who don’t know, Ubuntu ships with a package manager which can be used to install software packages. Some of these packages are not directly shipped with the Ubuntu, but are available in third-party software package repositories.

1.1 Installing Apache Maven

2.Installing Apache Maven is as simple as installing the right package in the repository.

sudo apt-get install maven

1.2 Verifying the install

Let’s just verify the installation.

mvn -v

2 Manual Installation

There is always ways to install them manually if you come across some issue for some weird reason.

2.1 Downloading Apache Maven

The Maven binaries are available on the Apache’s Servers or mirror sites which can be obtained from the following page.

wget http://www-us.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz

2.2 Unzipping Maven binaries to a installation location.

The archive directly contains the binaries you can use, let’s unzip it and store in an appropriate location.

sudo tar xzvf apache-maven-3.5.0-bin.tar.gz -C /usr/share/

2.3 Setting the binary location

This is required so that your new installation is reachable from the command line.

sudo update-alternatives --install /usr/bin/mvn mvn /usr/share/apache-maven-3.5.0/bin/mvn 9999

2.4 Updating the default alternative (Optional)

If you have already installed Maven before in the system, you might have to instruct Ubuntu to pickup the new installation. Let’s do that with the following command and follow the instruction.

sudo update-alternatives --config java