How to Install Apache Maven on Ubuntu 20.04
Abstract: Step 3 – Verify Installation You have successfully installed and configured Apache Maven on your Ubuntu system. To find the current installed Maven ve
Apache Maven is a software project management and comprehension tool. Maven can manage a project’s build, reporting, and documentation from a central piece of information.
This tutorial will help you to install and configure Apache Maven on Ubuntu 20.04 LTS systems.
You may like:
- How to Install Gradle on Ubuntu 20.04
Apache Maven required Java language for running on any operating system. So first of all, Make sure you have Java installed on your system. also make sure you have installed JDK and JRE both.
java -version openjdk 11.0.7 2020-04-14 OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1) OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)
If you don’t have Java Development Kit installed on your system. Use the below command to install it.
sudo apt install default-jdkStep 1 – Installing Apache Maven on Ubuntu
You can download Apache maven from its official website or use following command to download Apache Maven 3.6.3 on your system.
cd /usr/local wget https://www-us.apache.org/dist/maven/maven-3/3.8.5/binaries/apache-maven-3.8.5-bin.tar.gz
Now extract downloaded archive using following command.
sudo tar xzf apache-maven-3.8.5-bin.tar.gz sudo ln -s apache-maven-3.8.5 mavenStep 2 – Setup Environment Variables
As you have downloaded pre-compiled Apache Maven files on your system. Now set the environments variables by creating new file /etc/profile.d/maven.sh.
sudo vi /etc/profile.d/maven.sh
Update the following content to file:
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 export M2_HOME=/usr/local/maven export MAVEN_HOME=/usr/local/maven export PATH=${M2_HOME}/bin:${PATH}
Save your file and close.
Next load the environment variables in current shell using following command.
source /etc/profile.d/maven.shStep 3 – Verify Installation
You have successfully installed and configured Apache Maven on your Ubuntu system. To find the current installed Maven version, type:
mvn -version Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0) Maven home: /usr/local/maven Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64 Default locale: en, platform encoding: UTF-8 OS name: "linux", version: "5.4.0-26-generic", arch: "amd64", family: "unix"
Finally, cleanup the disk by removing the downloaded archive file.
rm -f apache-maven-3.8.5-bin.tar.gzConclusion
In this tutorial, You have learned about the installation of Apache Maven on Ubuntu system.