Trending News
By using our website, you agree to the use of our cookies.

Blog

How To Install Apache Maven on Ubuntu 18.04 & 16.04 Easy Guide
How To

How To Install Apache Maven on Ubuntu 18.04 & 16.04 Easy Guide 

Install Apache Maven is a project management and comprehension tool for software development projects. Maven can monitor the build, reporting, and documentation of a project from a single place. Install Apache Maven on Ubuntu 19.10 LTS, 18.04 LTS, and 16.04 LTS systems using this tutorial.

Table of Contents

How To Install Apache Maven on Ubuntu?

In This Tutorial, we will walk you through the installation of Apache Maven on Ubuntu 18.04 & 16.04. Follow the steps mentioned below to begin and complete the installation of Apache Maven on your system.

Step 1: Install Java

First and foremost, ensure that you have the latest version of Java installed on the system. Installing Apache Maven on a nix framework necessitates the use of Java. To start, you must first install Java on your system, ensuring that both JDK and JRE are installed.

				
					java -version 

openjdk 11.0.6 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing)
				
			

If you do not have Java Development Kit installed on your system, you will need to install it. Visit Install Java 11 on Ubuntu for more details.

Step 2: Now Install Apache Maven on Ubuntu

After you have double-checked the system’s Java version. To get Apache Maven 3.6.3, go to the official website and download it, or use the command below.

				
					cd /usr/local
wget https://www-eu.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
				
			
Now run the following command to extract the downloaded archive.
				
					sudo tar xzf apache-maven-3.6.3-bin.tar.gz
sudo ln -s apache-maven-3.6.3 apache-maven
				
			

Step 3: Set The Environments Variables

You have pre-compiled Apache Maven files on your system, right? Create a new file called /etc/profile.d/maven.sh to set the environment variables.

				
					sudo vi /etc/profile.d/apache-maven.sh
				
			
and then add the following content
				
					export JAVA_HOME=/usr/lib/jvm/java-11-oracle
export M2_HOME=/usr/local/apache-maven
export MAVEN_HOME=/usr/local/apache-maven
export PATH=${M2_HOME}/bin:${PATH}
				
			

Now use the following command to load the environment variables into the current shell.

				
					source /etc/profile.d/apache-maven.sh
				
			

Step 4: Check/Verify The Installed Version of Maven

Apache Maven has been successfully installed and configured on your Ubuntu system. To check Maven’s version, run the command mentioned below.

				
					mvn -version

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/apache-maven
Java version: 11.0.2, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-oracle
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-147.3.1.el8_1.x86_64", arch: "amd64", family: "unix"
				
			
Finally, remove the downloaded archive file from your system’s local storage.
				
					rm -f apache-maven-3.6.3-bin.tar.gz
				
			
Visit this page to learn more about Apache Maven.
Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on reddit
Share on vk
Share on tumblr
Share on skype
Share on stumbleupon
Share on whatsapp
Share on email

Related posts

Leave a Reply