Thursday, September 4, 2025
HomeGuest BlogsHow to install Apache Maven on RHEL / CentOS 8

How to install Apache Maven on RHEL / CentOS 8

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-1.8.0.181.b13-9.el8.x86_64/jre
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 -DgroupId=com.mycompany.app \
-DartifactId=my-app \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DinteractiveMode=false

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/
my-app/
├── pom.xml
└── src
├── main
│ └── java
│ └── com
│ └── mycompany
│ └── app
│ └── App.java
└── test
└── java
└── com
└── mycompany
└── app
└── AppTest.java
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] BUILD SUCCESSFUL
[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.

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32261 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6626 POSTS0 COMMENTS
Nicole Veronica
11795 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11855 POSTS0 COMMENTS
Shaida Kate Naidoo
6747 POSTS0 COMMENTS
Ted Musemwa
7023 POSTS0 COMMENTS
Thapelo Manthata
6695 POSTS0 COMMENTS
Umr Jansen
6714 POSTS0 COMMENTS