• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to install Apache Maven in CentOS 7

{{postValue.id}}

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

Or

[root@linuxhelp ~]# echo $PATH
/opt/maven/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin

The installation and configuration procedure of Apache Maven on CentOS 7 is done without any glitches.

Tags:
elijah
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

which language used to build apache maven?

A

The JAVA language has been used to build the apache maven.

Q

what are the features of apache maven?

A

the features of apache maven are
 Simple project setup that follows best practices - get a new project or module started in seconds
 Consistent usage across all pr

Q

How do I prevent including JARs in WEB-INF/lib? I need a "compile only" scope?

A

The scope you should use for this is provided. This indicates to Maven that the dependency will be provided at run time by its container or the JDK, for example. Dependencies with this scope

Q

How do I list available plugins in apoche maven?

A

The "Available Plugins" page lists them and provides additional information. See https://maven.apache.org/plugins

Q

how to download the apache maven package in terminal?

A

official Apache web site. Execute the wget command followed by the download link
# wget http://www-eu.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.zip

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Isaiah ?
What is the use of SUID & SGID commands

How to set the special permissions to the files and folders using SUID and SGID commands...

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.