This brief guide shows how to install Apache Maven on Ubuntu Linux. If you are a beginner or a new user and want to install Apache Maven on your ubuntu Linux machine then this short tutorial is useful and handy for you.
Apache Maven is a free, powerful and open source software project management and comprehension tool that is used primarily for Java projects.
It is based on the concept of POM (project object model) that helps you to manage an entire project’s build process, including storing documents, reporting and more. Basically POM (project object model) is an XML file which is containing information about the project, configuration details, the project’s dependencies, and many more.
Installing Apache Maven on Ubuntu Linux is very easy and straightforward because Maven packages are available in Ubuntu official repositories. So you just need to run the apt get commands to install it in your Ubuntu system.
The versions installed using apt
package manager may not necessarily be the latest versions. If you really want to install the latest version of Maven then you need to download and install it manually yourself.
In this tutorial, we are going to use two methods for installing Skype:
apt
package managerAs mentioned above, installing Apache Maven on Ubuntu Linux using apt
package manager is very easy and straight-forward process. You just need to follow below steps:
sudo apt update
sudo apt install maven
When you run the command above, it will install the Apache Maven with all required dependencies.
mvn -version
The command above will display a output similar like below:
Apache Maven 3.5.2
Maven home: /usr/share/maven
Java version: 10.0.2, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
Using this method, you can get the latest version of Maven in your ubuntu system. To do that, follow the steps below:
Apache Maven is based on Java. So its require JDK (Java Development Kit) to be installed. For this, we will install OpenJDK by running the command below:
sudo apt update
sudo apt install default-jdk
To verify the OpenJDK installation, run the command below:
java -version
At the time of writing this guide, the latest version of Apache Maven is 3.8.3
. You can check the Maven – download page to see the latest versions.
To download the latest version( 3.8.3
), run the command below:
cd /tmp
wget https://dlcdn.apache.org/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.tar.gz
After download, extract the downloaded archive in the /opt directory by running command below:
sudo tar xf /tmp/apache-maven-*.tar.gz -C /opt
Next, create a symbolic link to the version folder to control Maven versions and updates. To that, run the command below:
sudo ln -s /opt/apache-maven-3.8.3 /opt/maven
The command above will create a symbolic link maven
that will point to the installation directory.
Later when the new version is released, you just need to extract the newer version and change the symbolic link to point to the latest version.
After that, you will need to set up its environment variables. To do that, create a new file named maven.sh
by running command below:
sudo nano /etc/profile.d/maven.sh
The new file created inside the /etc/profile.d/
directory.
Next, copy and pastes the below configuration into the new 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}
Save and close the file.
Next, run the commands below to make the script executable and load the environment variables:
sudo chmod +x /etc/profile.d/maven.sh
source /etc/profile.d/maven.sh
You can verify the Maven installation by display its version. To do that, run the command below:
mvn -version
It will display a output similar like below:
Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: /opt/maven
Java version: 11.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
That’s all
If you find any error and issue in above steps , please use comment box below to report.
The post How to Install Apache Maven on Ubuntu appeared first on Linux Tutorial Hub.
2024 was the GenAI year. With new and more performant LLMs and a higher number…
Canonical’s Kubernetes LTS (Long Term Support) will support FedRAMP compliance and receive at least 12…
Welcome to the Ubuntu Weekly Newsletter, Issue 878 for the week of February 2 –…
At Canonical, we firmly believe that delivering an outstanding, customer-centric support experience is impossible without…
I want to share how to install osTicket v1.14 for Ubuntu 20.04 server. osTicket written…
Now I want to share how to install WordPress on ubuntu 20.04 server. WordPress is…