How To Install Apache Maven on CentOS 8

How to install apache Maven on Centos 8

In this short tutorial we will learn how to install Apache Maven on CentOS 8 operating system.


Apache Maven is a popular build automation tool and dependency management tool used primarily for Java projects. It provides a comprehensive and flexible way to manage project dependencies, build and package Java applications, and manage the software development lifecycle. Apache Maven is a powerful and flexible build automation and dependency management tool that can help streamline the software development process for Java projects.

Here are some key features and benefits of Apache Maven:

  • Dependency management: Maven simplifies dependency management by automatically downloading and managing project dependencies from a central repository. This makes it easy to manage dependencies across multiple projects and ensures that the correct versions of dependencies are used.
  • Build automation: Maven automates the build process, making it easy to build, test, and package Java applications. It provides a simple, declarative way to define the build process, which makes it easy to maintain and update build scripts.
  • Convention over configuration: Maven follows a “convention over configuration” approach, which means that it provides sensible defaults and conventions for project layout, naming, and configuration. This makes it easy to get started with Maven and reduces the amount of boilerplate code needed to configure and build projects.
  • Plugins and extensions: Maven provides a rich set of plugins and extensions that can be used to extend its functionality and integrate with other tools and systems.
  • Integration with other tools: Maven integrates well with other tools and systems commonly used in Java development, such as Eclipse, IntelliJ, Jenkins, and Git.

Apache Maven Installation On CentOS 8


Apache Maven requires any system requirements :

  • Java Development Kit (JDK) Maven 3.3+ require JDK 1.7 or above to execute.
  • Disk Approximately 10MB is required for the Maven installation itself. In addition to that, additional disk space will be used for our local Maven repository. The size of your local repository will vary depending on usage but expect at least 500MB.
  • root account or user with sudo privilege.

As mentioned section above, if Apache Maven requires Java installed on the system. We will verify it by submitting command line :

$ java -version

Output :

[ramans@otodiginet ~]$ java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

If there were no Java installed on the system, then we need to install it first.

The Apache Maven installation steps will be described on several steps as shown below :

  1. Download source & extract files
  2. Setting environment variables
  3. Verifying Apache Maven Installation

1. Download and Extract Apache Maven Source

In this step, we will download Apache Maven and extract it to our directory. At this tutorial, we will use Apache Maven version 3.6.3.  To downloade Apache Maven tarball, we will use wget command line, as shown below :

$ wget

Output :

[ramans@otodiginet ~]$ wget
--2021-01-21 15:00:09--
Resolving (, 2a01:4f8:10a:201a::2
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9506321 (9.1M) [application/x-gzip]
Saving to: ‘apache-maven-3.6.3-bin.tar.gz’

apache-maven-3.6.3-bin.tar.gz 100%[==============================================>] 9.07M 856KB/s in 14s

2021-01-21 15:00:25 (664 KB/s) - ‘apache-maven-3.6.3-bin.tar.gz’ saved [9506321/9506321]

After download was completed done, then we will extract it by using command line :

$ tar -zxvf apache-maven-3.6.3-bin.tar.gz

Then we will create new sub-directory under /opt then submit th comand line  by submitting command line

[ramans@otodiginet ~]$ sudo mkdir /opt/maven
[sudo] password for ramans: 
[ramans@otodiginet ~]$ sudo mv apache-maven-3.6.3 /opt/maven

2. Setting Environment Variables

In this step, we will configure Apache Maven configuration. The Apache Maven configuration is located at /etc/profile.d/

$ sudo vi  /etc/profile.d/

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-
export M2_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
$ source /etc/profile.d/

3. Verifying Apache Maven Installation

After setting up environment, we will verify Apache Maven installation that was installed successfully, by querying its version.

# mvn -version

Output :

[root@otodiginet ~]# mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /opt/maven
Java version:, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-193.el8.x86_64", arch: "amd64", family: "unix"
[root@otodiginet ~]#

Apache Maven


In this short tutorial, we have learned how to install Apache Maven on CentOS 8.

(Visited 204 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *