Apache Maven is a project management software, managing building, reporting and documentation of a Java development project. imilar to how the make utility builds an executable from source code and libraries using a Makefile, Apache Ant builds a Java project from its source code and libraries by using a similar XML file.
Step #1 Check Java Version
JAVA is the first requirement for Apache. Verify you have JAVA SE 6 or Later form introduced in your framework. Utilization taking after order to check in the event that you have java introduced as of now on your framework.
# java -version
java version "1.8.0_121"
ava(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode, sharing)
If you don’t have Java Development Kit installed on your system. Visit install Java 8 on CentOS/RHEL 7/6/5
Step #2 Download Apache Maven
You can download the latest version from the page also or you can use below link to download Apache Maven.
# cd /opt
# wget http://www-eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
Step #3 Extract Apache Maven
Extract it using following command
# tar zxvf apache-maven-3.3.9-bin.tar.gz
Move the extracted contents using following command:
# mv apache-maven-3.3.9/ /opt/maven
Step #4 Make Symbolink
Make a symbolink to maven/bin folder as shown below.
# ln -s /opt/maven/bin/mvn /usr/bin/mvn
Step #5 Maven environment
Create a file and add the content as below to setup Maven environment variable:
# vim /etc/profile.d/maven.sh
Add the following contents:
export PATH MAVEN_HOME
Make it executable using the following command.
# chmod +x /etc/profile.d/maven.sh
Then, set the environment variables permanently by running the following command:
# source /etc/profile.d/maven.sh
Step #6 Check Version
You can check version using following command:
# mvn -version
Apache Maven 3.3.9 (a31e8fdf433f8c3e10d3cdebad265627c3ddde99; 2016-07-12T02:28:10+05:30)
Maven home: /opt/maven
Java version: 1.8.0_101, vendor: Oracle Corporation
Java home: /opt/jdk1.8.0_101/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "126.96.36.1992.el6.x86_64", arch: "amd64", family: "unix"
Check the environment variables:
# echo $MAVEN_HOME
# echo $PATH