How to Install Apache Maven on CentOS 8

Install Apache Maven on CentOS 8

In this article, we will have explained the necessary steps to install and configure Apache Maven on CentOS 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Apache Maven is free and open source, software project management and comprehension tool written in Java. Based on the concept of a project object model (POM), Maven can manage an entire project’s build. With Maven you can easily store documents, generate reports and documentation from a central piece of information.

Install Apache Maven CentOS 8

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

Step 2. Install Java.

Apache Maven requires Java to be installed on your system. To install OpenJDK 8 run following command in terminal:

To verify that Java was successfully installed, run the following command:

Step 3. Install Apache Maven.

First, download Apache Maven from official Apache release page. The latest Gradle version available is 3.6.3:

Now extract downloaded tar.gz file using following command:

Step 4. Setup environment variables.

Next step is to configure the PATH environment variable to include the Gradle bin directory. To do so, open your text editor and create a new file named maven.sh inside of the /etc/profile.d/ directory:

Add the following content:

Now load the environment variables in the current shell using the following command:

Check whether the Apache Maven has been successfully configured on your system using the below command:

Congratulation, you have learned how to install and configure Apache Maven on CentOS 8. If you have any question, please leave a comment below.