February 7, 2023

How To Install Apache Maven On Ubuntu 20.04

Abhishek Thakur


Maven, the Yiddish word for knowledge accumulator. It started as an attempt to simplify the construction process for the Jakarta Turbine Project.  The idea behind Maven was to structure ongoing  projects, with a clear definition of what the project consisted of. And an easy way to share them across multiple Java projects.The result was a tool that can be used to create and manage Java-based projects. Which made the Java developers day-to-day life more fun and easy. In this guide we will learn how to install Apache Maven on Ubuntu 20.04.

Requirements

  • 99RDP VPS/Dedicated Server
  • Terminal Access

Steps To Install OpenJDK for Apache Maven

You can install Maven on Linux in a few easy steps. The first step is to install the JDK required to run Maven. Let’s start, at first SSH into your server and update the basic repo and software packages list by entering the given command in terminal.

# apt update && apt upgrade -y

Once the update is finished we can proceed with the JDK installation, to do so visit the given link https://jdk.java.net/19/ to download the latest Java JDK and run the given command in terminal. For us the latest version is OpenJDK JDK 19.0.2.

# wget https://download.java.net/java/GA/jdk19.0.2/fdb695a9d9064ad6b064dc6df578380c/7/GPL/openjdk-19.0.2_linux-x64_bin.tar.gz

Once the download is finished extract the tar file and move it to your location of choice for us it’s /usr/local. Extract the tar file using the given command.

# tar -xvf openjdk-19.0.2_linux-x64_bin.tar.gz

Next we are going to move the extracted folder to /usr/local to do so enter the given command in terminal.

# mv jdk-19.0.2 /usr/local

Following we have to setup the JAVA home and path variable for the whole system. To do that open .profile from the home directory and enter the given lines at the end of it.

# nano .profile

JAVA_HOME='/usr/local/jdk-19.0.2'
PATH="$JAVA_HOME/bin:$PATH" 
export PATH

Once the path is set reload the .profile file using the given command.

# source .profile

Now we can verify the JAVA installation using the given command.

# java -version

Java Version

 

Steps To Install Apache Maven On Ubuntu 20.04

For Apache Maven the installation process is similar to the OpenJDK installation. At first visit the link https://maven.apache.org/download.cgi and copy the binary tar file link and download it using the wget command.

# wget https://dlcdn.apache.org/maven/maven-3/3.9.0/binaries/apache-maven-3.9.0-bin.tar.gz

Once the download is finished extract the apache-maven-3.9.0-bin.tar.gz file using the given command and move it to /usr/local or the directory of your choice similarly to the OpenJDK.

# tar -xvf apache-maven-3.9.0-bin.tar.gz

# mv apache-maven-3.9.0 /usr/local

Once the folder is moved to /usr/local we need to set it’s home and path variable to.profile file. You can do that by pasting the given line of codes in the .profile file.

M2_HOME='/usr/local/apache-maven-3.9.0'
PATH="$M2_HOME/bin:$PATH"
export PATH

# nano .profile

Save the file and reload the .profile file using the given command.

# source .profile

Finally we can verify the installation process by checking the current maven version using the given command.

# mvn -version

Pache Maven Version

 

Conclusion

That’s it the latest version of OpenJDK and Maven is installed in your system successfully. Finally you have a development environment for Apache Maven latest build. Thank You for your time.


Buy Apache Maven Devlopment Server @ $10.99/m Only

Popular Blog Posts