Prerequisites
The user you are logging in as must have sudo privileges to be able to install packages.
Installing Apache Maven on CentOS with Yum
Installing Maven on CentOS 7 using yum
is a simple, straightforward process.
Install Maven by typing the following command in your terminal:
sudo yum install maven
Verify the installation by typing the
mvn -version
command:mvn -version
The output should look something like this:
Apache Maven 3.0.5 (Red Hat 3.0.5-17) Maven home: /usr/share/maven Java version: 1.8.0_191, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-862.3.2.el7.x86_64", arch: "amd64", family: "unix"
That’s it. Maven is now installed on your CentOS system and you can start using it.