Cyberithub

Best Steps to Install Apache Maven on Ubuntu 20.04

Advertisements

In this article, I will take you through the best steps to Install Apache Maven on Ubuntu 20.04. Maven is a free and open source build automation tool mostly used for building Java based projects. It can also be used to build and manage projects written on C#, Ruby, Scala and other high level languages. Apache Maven is available as a plugin software which can be easily integrated with other DevOps tools like Jenkins. There are multiple ways to install Apache maven on Ubuntu based Server but we will look into the most simplest one using apt utility. More on Maven docs.

Best Steps to Install Apache Maven on Ubuntu 20.04

Steps to Install Apache Maven on Ubuntu 20.04

Also Read: Best Steps to Install Atom Text Editor on Ubuntu 20.04

Step 1: Prerequisites

a) You should have running Ubuntu 20.04 Server.

b) You should have sudo or root access to run privileged commands.

b) You should have apt utility installed in your Server.

Step 2: Update Your Server

Before going through the steps to install Apache maven, first let's sync all the installed packages with the latest available release on Ubuntu repo using apt update command as shown below.

root@localhost:~# apt update
Hit:1 http://in.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:5 http://ppa.launchpad.net/micahflee/ppa/ubuntu focal InRelease [17.5 kB]
Get:6 https://packages.microsoft.com/repos/edge stable InRelease [7,343 B]
Get:7 http://in.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [499 kB]
Get:8 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1,077 kB]
Get:9 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [282 kB]
Get:10 http://in.archive.ubuntu.com/ubuntu focal-updates/main DEP-11 48x48 Icons [60.5 kB]
Get:11 http://in.archive.ubuntu.com/ubuntu focal-updates/main DEP-11 64x64 Icons [95.1 kB]
Get:12 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [13.6 kB]
Get:13 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [825 kB]

 

Step 3: Install Apache Maven

To install Maven on your System, you can use apt install maven command as shown below. This will download and install maven package along with its dependencies from Ubuntu Repo.

Advertisements

NOTE:

Please note that here I am using root user to run all the below commands. You can use any user with sudo access to run all these commands. For more information Please check Step by Step: How to Add User to Sudoers to provide sudo access to the User.
root@localhost:~# apt install maven
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libatomic1 linux-headers-5.8.0-53-generic linux-hwe-5.8-headers-5.8.0-53 linux-image-5.8.0-53-generic linux-modules-5.8.0-53-generic
linux-modules-extra-5.8.0-53-generic
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
libaopalliance-java libapache-pom-java libatinject-jsr330-api-java libcdi-api-java libcommons-cli-java libcommons-io-java libcommons-lang3-java
libcommons-parent-java libgeronimo-annotation-1.3-spec-java libgeronimo-interceptor-3.0-spec-java libguava-java libguice-java libhawtjni-runtime-java
libjansi-java libjansi-native-java libjsr305-java libmaven-parent-java libmaven-resolver-java libmaven-shared-utils-java libmaven3-core-java
libplexus-cipher-java libplexus-classworlds-java libplexus-component-annotations-java libplexus-interpolation-java libplexus-sec-dispatcher-java
libplexus-utils2-java libsisu-inject-java libsisu-plexus-java libslf4j-java libwagon-file-java libwagon-http-shaded-java libwagon-provider-api-java

 

Step 4: Upgrade Maven

If you want to use the latest Maven version then you can always upgrade it by using apt upgrade maven command as shown below.

root@localhost:~# apt upgrade maven
Reading package lists... Done
Building dependency tree
Reading state information... Done
maven is already the newest version (3.6.3-1).

 

Step 5: Check Maven Version

To check if maven is correctly installed and working properly, you can check its installed version by using mvn -v command. As you can see below, current maven version is 3.6.3.

root@localhost:~# mvn -v
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "5.8.0-59-generic", arch: "amd64", family: "unix"

 

Step 6: Remove Apache Maven

Once you are done with Maven, you can uninstall it by simply by using apt remove maven command as displayed below.

root@localhost:~# apt remove maven
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libaopalliance-java libapache-pom-java libatinject-jsr330-api-java libatomic1 libcdi-api-java libcommons-cli-java libcommons-io-java
libcommons-lang3-java libcommons-parent-java libgeronimo-annotation-1.3-spec-java libgeronimo-interceptor-3.0-spec-java libguava-java libguice-java
libhawtjni-runtime-java libjansi-java libjansi-native-java libjsr305-java libmaven-parent-java libmaven-resolver-java libmaven-shared-utils-java
libmaven3-core-java libplexus-cipher-java libplexus-classworlds-java libplexus-component-annotations-java libplexus-interpolation-java
libplexus-sec-dispatcher-java libplexus-utils2-java libsisu-inject-java libsisu-plexus-java libslf4j-java libwagon-file-java libwagon-http-shaded-java
libwagon-provider-api-java linux-headers-5.8.0-53-generic linux-hwe-5.8-headers-5.8.0-53 linux-image-5.8.0-53-generic linux-modules-5.8.0-53-generic
linux-modules-extra-5.8.0-53-generic
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
maven
0 upgraded, 0 newly installed, 1 to remove and 157 not upgraded.
After this operation, 127 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 226820 files and directories currently installed.)
Removing maven (3.6.3-1) ...

Leave a Comment