How to install Maven on CentOS

Last updated on October 14, 2020 by Dan Nanni

Apache Maven is a project management software, managing building, reporting and documentation of a Java-based development project. In order to install and configure Apache Maven on CentOS, follow these steps.

First of all, you need to install Java development kit (JDK). Make sure to install JDK, not Java Runtime Environment (JRE).

Then go ahead and download the latest Maven binary from its official site. For example, for version 3.0.4:

$ wget
$ sudo tar xzf apache-maven-3.0.4-bin.tar.gz -C /usr/local
$ cd /usr/local
$ sudo ln -s apache-maven-3.0.4 maven

Next, set up Maven path system-wide:

$ sudo vi /etc/profile.d/
export M2_HOME=/usr/local/maven
export PATH=${M2_HOME}/bin:${PATH}

Finally, log out and log in again to activate the above environment variables. To verify successful installation of Maven, check the version of Maven:

$ mvn -version

Use Maven Behind Proxy

Optionally, if you are using Maven behind a proxy, you must define the proxy as follows.

$ vi ~/.m2/settings.xml

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean