How to install Apache Maven in CentOS 7
To install Apache Maven in CentOS 7
Apache Maven is a project management tool for managing building, reporting and documenting of Java-based development project. It contains a project object model, a set of standards, a project lifecycle, a dependency management system and logic. Maven is designed to provide a simplet project setup for users to have an easy environment.Maven addresses two parts of building a software, first it describes how a software is built and second its dependencies. This tutorial covers the installation procedure of Apache Maven on CentOS 7.
Installation and configuration procedure
To proceed with the installation procedure, check whether the target system is installed with Java Development Kit, because Apache Maven will use JDK during its build process. For this tutorial, the system has already been installed with JDK and to check the version of the Java that is installed, run the following command.
[root@linuxhelp ~]# java -version
java version " 1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
After the JDK is installed and version has been checked, go ahead and install Apache Maven using its binary distribution from the official Apache web site. Execute the wget command followed by the download link.
[root@linuxhelp ~]# wget http://www-eu.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.zip
--2017-09-22 20:48:39-- http://www-eu.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.zip
Resolving www-eu.apache.org (www-eu.apache.org)... 62.210.60.236, 88.198.26.2, 2001:bc8:2142:200::2, ...
Connecting to www-eu.apache.org (www-eu.apache.org)|62.210.60.236|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8691883 (8.3M) [application/zip]
Saving to: ‘ apache-maven-3.5.0-bin.zip’
100%[=======================================================> ] 8,691,883 27.9MB/s in 0.3s
2017-09-22 20:49:04 (27.9 MB/s) - ‘ apache-maven-3.5.0-bin.zip’ saved [8691883/8691883]
The package has been downloaded and now extract it using unzip command as follows.
[root@linuxhelp ~]# unzip apache-maven-3.5.0-bin.zip
Archive: apache-maven-3.5.0-bin.zi
creating: apache-maven-3.5.0/
creating: apache-maven-3.5.0/lib/
creating: apache-maven-3.5.0/lib/jansi-native/
creating: apache-maven-3.5.0/lib/jansi-native/linux32/
creating: apache-maven-3.5.0/lib/jansi-native/linux64/
creating: apache-maven-3.5.0/lib/jansi-native/osx/
creating: apache-maven-3.5.0/lib/jansi-native/windows32/
creating: apache-maven-3.5.0/lib/jansi-native/windows64/
creating: apache-maven-3.5.0/bin/
creating: apache-maven-3.5.0/conf/
creating: apache-maven-3.5.0/conf/logging/
.
.
inflating: apache-maven-3.5.0/lib/wagon-file-2.12.jar
inflating: apache-maven-3.5.0/lib/maven-resolver-transport-wagon-1.0.3.jar
Move the extracted contents to /opt/ directory.
[root@linuxhelp ~]# mv apache-maven-3.5.0/ /opt/maven
Make a symlink to maven/bin folder as shown below.
[root@linuxhelp ~]# ln -s /opt/maven/bin/mvn /usr/bin/mvn
Setup ANT Environment Variable
Create a file called maven.sh under /etc/profile.d/ directory. Add the following contents and save the file.
[root@linuxhelp ~]# vim /etc/profile.d/maven.sh
#!/bin/bash
MAVEN_HOME=/opt/maven
PATH=$MAVEN_HOME/bin:$PATH
export PATH MAVEN_HOME
export CLASSPATH=.
Make it executable by executing the following command.
[root@linuxhelp ~]# chmod +x /etc/profile.d/maven.sh
Then, set the environment variables permanently by running the following command.
[root@linuxhelp ~]# source /etc/profile.d/maven.sh
The environment variable are set. For the changes to make effect, log out or reboot your system. After the system comes back online, check the ANT version by executing the following command.
[root@linuxhelp ~]# mvn -version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426 2017-04-04T01:09:06+05:30)
Maven home: /opt/maven
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: /opt/jdk1.8.0_121/jre
Default locale: en_US, platform encoding: UTF-8
OS name: " linux" , version: " 3.10.0-123.el7.x86_64" , arch: " amd64" , family: " unix"
Check the path and environment variables present by running either of the commands.
[root@linuxhelp ~]# echo $MAVEN_HOME
/opt/maven
Simple project setup that follows best practices - get a new project or module started in seconds
Consistent usage across all pr
# wget http://www-eu.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.zip