Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. Maven can also be used to build and manage projects written in C#, Ruby, Scala, and other languages.

In this guide, we will install Apache Maven on CentOS 7.

Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can quickly deploy your cloud servers.

Once you have signed up, log into your Cloudwafer Client Area with the password provided in your mail and deploy your Cloudwafer cloud server.

Updating System Packages
It is recommended that you update the system to the latest packages before beginning any significant installations. Issue the command below:

sudo yum update -y

You can install Apache Maven from the official Yum Repositories by issuing the sudo yum install maven. However, this might be an older version when compared to downloading Maven from its official website.

Step 1: Install OpenJDK
Maven 3.3+ require JDK 1.7 or above to execute. You can follow the steps in this guide to install OpenJDK on your CentOS 7 system.

You can check the default Java by issuing the command below:

java -version

Step 2: Download Apache Maven
At the time of writing this guide, Apache Maven 3.6.3 is the latest version. You can visit the Apache Maven download page to check for a newer version.

cd /tmp
wget https://www-us.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz

After downloading, extract the downloaded archive into the /opt directory:

sudo tar xf apache-maven-3.6.3-bin.tar.gz -C /opt

Next, create a symbolic link by issuing the command below:

sudo ln -s /opt/apache-maven-3.6.3 /opt/maven

Step 3: Setup Environment Variables
After downloading, extracting and creating a symbolic link, we are going to set up environmental variables. First, create a new file named mavenenv.sh inside of the /etc/profile.d/ directory.

sudo nano /etc/profile.d/maven.sh

Next, make the script executable and load the environment variables by issuing the following commands:

sudo chmod +x /etc/profile.d/maven.sh
source /etc/profile.d/maven.sh

To verify that Apache Maven is installed, issue the command below which will print the Maven version installed:

mvn -version

You can visit the official Apache Maven Documentation page for more information on Apache Maven