
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.
Prerequisites:
Before you begin the installation process, ensure that you have the following prerequisites in place:
- A CentOS server (preferably the latest version) with root access or a user with sudo privileges.
- 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 updateStep 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-develVerify the installation by running the following command:
java -versionYou should see the Java version information displayed.
Step 3: Download and Extract Apache Maven
Visit the Apache Maven download page (https://maven.apache.org/download.cgi) 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.gzStep 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 ~/.bashrcAdd the following lines at the end of the file:
export MAVEN_HOME=/opt/apache-maven-<version>
export PATH=$PATH:$MAVEN_HOME/binReplace <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 ~/.bashrcStep 5: Verify Maven Installation
Verify that Maven is successfully installed by running the following command:
mvn -versionYou should see the Maven version information displayed, confirming that Maven is installed correctly.
Conclusion:
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
- Apache Maven Official Website: https://maven.apache.org/
- CentOS Official Website: https://www.centos.org/
- Java SE Development Kit (JDK) Official Website: https://www.oracle.com/java/technologies/javase-jdk8-downloads.html





Leave a Reply