How to Install Apache Maven on Ubuntu
How to Install Apache Maven on Ubuntu
Apache Maven is a free and open-source project management and comprehension tool used primarily for Java projects. Maven uses a Project Object Model (POM), which is essentially an XML file containing information about the project, configuration details, the project's dependencies, and so on.
In this tutorial, we will take you through two different ways to install Apache Maven on Ubuntu.
The official Ubuntu repositories contain Maven packages that can be installed with the apt package manager. This is the easiest way to install Maven on Ubuntu. but it may not be the latest maven repository available.
To install the latest version of Maven we will be downloading Maven from their official website. Choose the installation method that is suits you.
Installing Apache Maven on Ubuntu with apt package manager
Installing Maven on Ubuntu using apt is a simple, straightforward process.
Start by updating the package repositories:
root@scdf-server-75b598cc56-b64hs:/# apt update
Next, install Maven by typing the following command:
root@scdf-server-75b598cc56-b64hs:/# apt install maven
Verify the installation by running the mvn -version command:
root@scdf-server-75b598cc56-b64hs:/# mvn -version
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 1.8.0_192, vendor: Oracle Corporation, runtime: /opt/openjdk
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.1.3.el7.x86_64", arch: "amd64", family: "unix"
root@scdf-server-75b598cc56-b64hs:/#
Cheers. Maven is now installed .
Install the Latest Release of Apache Maven
1. Install OpenJDK
Maven 3.6.X requires JDK 1.8 to be installed. We'll install OpenJDK.
Start by updating the package index:
root@scdf-server-75b598cc56-b64hs:/# apt update
Install the OpenJDK package by typing:
root@scdf-server-75b598cc56-b64hs:/# apt install default-jdk
Verify the installation by running the following command:
root@scdf-server-75b598cc56-b64hs:/# java -version
openjdk version "1.8.0_192"
OpenJDK Runtime Environment (build 1.8.0_192-b12)
OpenJDK 64-Bit Server VM (build 25.192-b12, mixed mode)
root@scdf-server-75b598cc56-b64hs:/#
2. Download Apache Maven
Download latest Maven:
wget https://www-us.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -P /tmp
Once the download is completed, extract the archive in the /opt directory:
root@scdf-server-75b598cc56-b64hs:/# tar xf /tmp/apache-maven-*.tar.gz -C /opt
root@scdf-server-75b598cc56-b64hs:/# ln -s /opt/apache-maven-3.6.3 /opt/maven
Later if you want to upgrade your Maven installation you can simply unpack the newer version and change the symlink to point to the latest version.
3. Setup environment variables
update your profile file with following detils:
export JAVA_HOME=/usr/lib/jvm/default-java
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
Reload the environment variables :
source /etc/profile
4. Verify the installation
To validate that Maven is installed properly use following command
mvn -version
You should see something like the following:
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 1.8.0_192, vendor: Oracle Corporation, runtime: /opt/openjdk
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.1.3.el7.x86_64", arch: "amd64", family: "unix
0 Response to "How to Install Apache Maven on Ubuntu"
Post a Comment