This tutorial serves as a step by step guide on how to install Apache Maven on RHEL / CentOS 8. Apache Maven is a software project management and automation tool used for managing the Java project’s build, reporting, and documentation from a central piece of information.

For CentOS 7 / Fedora: Installing Latest Apache Maven on CentOS 7 / Fedora

For Debian / Ubuntu use: Install Latest Apache Maven on Ubuntu / Debian

The Apache Maven package is available on RHEL 8 upstream repositories. Run the command below as a user with sudo privileges.

sudo yum -y install @maven

Java will be installed as a dependency. Wait for the installation to finish then check the version of Apache Maven installed on your RHEL 8 system.

$ mvn --version
Apache Maven 3.5.4 (Red Hat 3.5.4-5)
Maven home: /usr/share/maven
Java version: 1.8.0_181, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-32.el8.x86_64", arch: "amd64", family: "unix"

All options are available on:

$ mvn -h

Testing Apache Maven on RHEL / CentOS 8

Create Maven projects directory:

mkdir ~/mvn-projects && cd ~/mvn-projects

Create your first project:

mvn archetype:generate \
-DartifactId=my-app \
-DarchetypeArtifactId=maven-archetype-quickstart \

Since this is the first run,  it may take a while to execute.  This is because Maven is downloading the most recent artifacts (plugin jars and other files) into your local repository.

$ tree my-app/
├── pom.xml
└── src
├── main
│ └── java
│ └── com
│ └── mycompany
│ └── app
│ └──
└── test
└── java
└── com
└── mycompany
└── app
11 directories, 3 files
  • The src/main/java directory contains the project source code
  • The src/test/java directory contains the test source
  • The file pom.xml is the project’s Project Object Model (POM).

The filepom.xml is the core of a project’s configuration in Maven. It contains the majority of information required to build a project.

Build the Project

To build your Project, run:

mvn package

The command line will print out various actions, and end with the following:

[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Thu Jab 24 22:14:10 EAT 2018
[INFO] Final Memory: 2M/6M
[INFO] ------------------------------------------------------------------------

That’s all. Read Official Maven Documentation for further learning.

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here