How to install Apache Maven on CentOS 7

install Apache Maven,Apache Maven,Centos

Introduction: Step-by-Step Guide: How to Install Apache Maven on CentOS

Apache Maven is a powerful build automation tool widely used in Java projects for managing dependencies and building applications. If you’re looking to install Apache Maven on CentOS, this comprehensive guide will walk you through the process. By following these instructions, you’ll have Maven installed and ready to use, enhancing your Java development workflow.


Before you begin the installation process, ensure that you have the following prerequisites in place:

  1. A CentOS server (preferably the latest version) with root access or a user with sudo privileges.
  2. Java Development Kit (JDK) installed on your system. Maven requires Java to run.

Now, let’s proceed with the installation process.

Step 1: Update System Packages
Start by updating your CentOS server’s packages to their latest versions:

sudo yum update

Step 2: Install Java Development Kit (JDK)
Maven requires Java to run. Install the JDK using the following command:

sudo yum install java-1.8.0-openjdk-devel

Verify the installation by running the following command:

java -version

You should see the Java version information displayed.

Step 3: Download and Extract Apache Maven
Visit the Apache Maven download page ( and copy the link address for the latest stable release of Maven. On your CentOS server, change to the directory where you want to install Maven and download the TAR.GZ file using the wget command:

cd /opt
sudo wget <paste the copied link address here>

Replace <paste the copied link address here> with the link address, you copied from the Maven download page.

Extract the downloaded TAR.GZ file using the following command:

sudo tar -xvf apache-maven-*.tar.gz

Step 4: Configure Environment Variables
To use Maven from anywhere in the system, you need to configure the environment variables. Open the .bashrc file in a text editor:

sudo nano ~/.bashrc

Add the following lines at the end of the file:

export MAVEN_HOME=/opt/apache-maven-<version>

Replace <version> with the specific version number of Maven you downloaded.

Save the file and exit the text editor.

To apply the changes, run the following command:

source ~/.bashrc

Step 5: Verify Maven Installation
Verify that Maven is successfully installed by running the following command:

mvn -version

You should see the Maven version information displayed, confirming that Maven is installed correctly.


Congratulations! You have successfully installed Apache Maven on your CentOS server. By following the steps outlined in this guide, you can now take advantage of Maven’s powerful features for managing dependencies and building your Java projects. Boost your productivity and streamline your development process by leveraging Maven’s capabilities.

Useful Links for Reference

  1. Apache Maven Official Website:
  2. CentOS Official Website:
  3. Java SE Development Kit (JDK) Official Website:


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.