You are here:

Installation of Apache Maven on CentOS 8

Installation

Begin by updating CentOS.

  1. Yum update
  2. Confirm the download with ‘Y‘.
  3. Wait until the update is finished.

To install Maven 3.3+ on CentOS, ensure you have JDK 1.7 or above. As of the latest update, Maven 3.6.3 is the recommended version.

  1. Yum install java-11-openjdk-devel
  2. Confirm the download with ‘Y‘.
  3. Check if the installation succeeded with: java -version
  1. Download the Maven files with: wget https://mirror.novg.net/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
  2. Extract the files to /opt with: tar xf apache-maven-3.6.3-bin.tar.gz -C /opt
  3. Establish a symbolic link for easier Maven updates with the command: `ln -s /opt/apache-maven-3.6.3 /opt/maven

Configuration Configuration of Maven

  1. Create the file named maven.sh into /etc/profile.d/ with: nano /etc/profile.d/maven.sh
  2. Fill the file with the following code:
export JAVA_HOME=/usr/lib/jvm/jre-openjdk
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
  1. Save and exit the file.
  2. Make the file executable: chmod +x /etc/profile.d/maven.sh
  3. Load the file with: source /etc/profile.d/maven.sh

Verify the correct installation of Maven by employing the following command: mvn -version

Maven is now installed onto your VPS.

Was this article helpful?
Dislike 0