How to Install Apache Maven on Arch Linux

Apache Maven is a popular build tool used to manage Java software projects. This tutorial will guide you through the steps to install Apache Maven on your Arch Linux system.

Prerequisites

Before you begin the installation, make sure that you have the following prerequisites:

Step 1: Install OpenJDK

Apache Maven requires Java to be installed on the system. In this step, we will install OpenJDK, an open-source implementation of the Java Development Kit.

First, update the package repositories and install OpenJDK:

sudo pacman -Syu jdk-openjdk

Verify the installation by checking the Java version:

java -version

The output should show the installed version of OpenJDK.

Step 2: Download Apache Maven

Next, visit the official Apache Maven website and download the latest binary distribution from the downloads page. Alternatively, you can use wget to download the file directly from the command line:

wget https://apache.mirror.digitalpacific.com.au/maven/maven-3/3.8.2/binaries/apache-maven-3.8.2-bin.tar.gz

The filename may be different depending on the version and mirror you choose.

Step 3: Extract the Archive

Once the download is complete, extract the downloaded archive to the /opt directory:

sudo tar xf apache-maven-*.tar.gz -C /opt/

This will create a directory named apache-maven-X.X.X in the /opt directory, where X.X.X is the version number.

Step 4: Configure Environment Variables

Apache Maven requires the JAVA_HOME environment variable to be set to the installation directory of OpenJDK. In addition, you should add the bin directory of Apache Maven to your PATH.

Edit the /etc/environment file using your preferred text editor:

sudo nano /etc/environment

Add the following lines to the end of the file:

JAVA_HOME=/usr/lib/jvm/default
PATH="$PATH:/opt/apache-maven-X.X.X/bin"

Replace X.X.X with the version number of Apache Maven that you downloaded.

Save and close the file.

Step 5: Apply Environment Changes

To apply the changes made to the /etc/environment file, log out of your user account and log back in.

Alternatively, you can also run the following command to load the new environment variables in the current terminal session:

source /etc/environment

Step 6: Verify the Installation

To verify that Apache Maven is installed and configured correctly, run the following command to print the Maven version:

mvn --version

You should see the version of Apache Maven that you installed, along with the version of Java that it is using.

Congratulations, you have successfully installed Apache Maven on your Arch Linux system!

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!