Share your love
Install and Configure Apache Maven on Rocky Linux 8

This guide intends to teach you to Install and Configure Apache Maven on Rocky Linux 8. Maven is a powerful project management tool that is based on POM (project object model). It is used for project build, dependency, and documentation. It simplifies the build process like ANT. But it is too much more advanced than ANT.
In short terms we can tell maven is a tool that can be used for building and managing any Java-based project. maven makes the day-to-day work of Java developers easier and generally helps with the comprehension of any Java-based project.
You can now proceed to the guide steps below on the Orcacore website to install Maven on Rocky Linux 8.
Table of Contents
Steps To Install and Configure Apache Maven on Rocky Linux 8
To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on Initial Server Setup with Rocky Linux 8.
In this guide, We’ll be downloading the latest release of Apache Maven from their official website.
1. Install OpenJDK for Maven
Maven 3.3+ requires JDK 1.7 or above to be installed on your Rocky Linux 8.
First, update your local package index with the following command:
sudo dnf update -y
Then, use the command below to install the OpenJDK package on Rocky Linux 8:
sudo dnf install java-1.8.0-openjdk -y
At this point, Verify your Java installation by checking its version:
java -version

2. Install Maven on Rocky Linux 8
You need to visit the Apache Maven downloads page and copy the link address of the binaries package.
Download Maven
Next, use the wget command to download it on your server in the tmp directory:
sudo wget https://dlcdn.apache.org/maven/maven-3/3.8.7/binaries/apache-maven-3.8.7-bin.tar.gz -P /tmp
At this point, you need to extract your downloaded file in the opt directory:
sudo tar xf /tmp/apache-maven-3.8.7-bin.tar.gz -C /opt
Create Symbolic Link for Maven
Now you should create a symbolic link that will point to the Maven installation directory on Rocky Linux:
sudo ln -s /opt/apache-maven-3.8.7 /opt/maven
Note: To upgrade your Maven installation, simply unpack the newer version and change the symlink to point to it.
Set up Maven Environment Variables
At this point, you should set up the Maven environment variables on Rocky Linux 8. To do this, use your favorite text editor to create a new file inside the /etc/profile.d directory:
sudo vi /etc/profile.d/maven.sh
Add the following content to the file:
export JAVA_HOME=/usr/lib/jvm/jre-openjdk
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
When you are done, save and close the file.
Next, make your file executable with the following command:
sudo chmod +x /etc/profile.d/maven.sh
Load the Maven environment variables on Rocky Linux 8 with the following command:
source /etc/profile.d/maven.sh
At this point, you can verify your Maven installation by checking its version:
mvn -version

That’s it. The latest version of Apache Maven is now installed on your Rocky Linux system.
Conclusion
At this point, you have learned to Install and Configure Apache Maven on Rocky Linux 8. Maven in Rocky Linux 8 is used for managing Java projects by automating builds, dependencies, and project lifecycles. It simplifies compiling, testing, and packaging Java applications.
Hope you enjoy it. You may also like these articles too:
Fix PuTTY Server Refused Our Key Error
Install Postman on Rocky Linux 8
Install Python 3.11 on Rocky Linux 8
How To Install Ntopng on Rocky Linux 9
How To Install Joomla With LAMP Stack On Rocky Linux 9