tutorials questions & answers
jessy.vanbaal@vpsserver.com by Pinkman

How to install Apache Maven on CentOS 8

TAGS:
  • Maven
  • apache
  • CentOS 8

Installation

Start by running CentOS updates

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

Install required packages
Maven 3.3+ require JDK 1.7 or above to execute.
At the time of writing, Maven 3.6.3 is the latest version.

  1. Yum install java-11-openjdk-devel
  2. Confirm the download with ‘Y’.
  3. Check if the installation succeeded with: java -version

Install Maven
Now we are ready to install Maven.

  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. Create a Symbolic Link so that it is easier to update Maven in the future: 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. Now load the file with: source /etc/profile.d/maven.sh

To check if Maven is installed correctly use the following command: mvn -version

Maven is now installed onto your VPS.

comments (0)

    leave comment

    Please choose login or register to comment in this thread.

    Start now for as low as $4,99 a month!

    • 8 Characters2
    • 1 Uppercase Atleast
    • 1 Number Atleast