Apache Maven Installation

This article provides step by step tutorial of Apache Maven installation. The tutorial uses linux but can be easy reproduced on windows or mac.


Apache Maven is Software Project Management and Configuration tool. Through it's bride acceptance in the java-developer community it introduces some kind of unification and standardisation in a structure of java Software projects. Long story short at the end of every build some artifacts (e.g .jar files) are produced, deployed, archived, copied to location here there are referenced and so on. Maven provides basic support for all this tasks. Therefore  if you're interested in professional software development, clean versioning, clear dependency management but didn't know how to start with maven easy consider to install maven like described here and to understand it by my next article.


I think some command annotation is enough. Pleas feel free to ask in comments if something is fussy.

#Download actual release
cd /tmp  
wget http://apache.linux-mirror.org/maven/binaries/apache-maven-3.0.4-bin.tar.gz  
#create target dir
mkdir  /usr/lib/apache-maven/  
#change to it.
cd /usr/lib/apache-maven/  
#extract downloadet files
tar -xzf /tmp/apache-maven-3.0.4-bin.tar.gz  

So basic maven is installed, but is not configured so far. To be complete some environment variables need to be exposed.

export M2_HOME=/usr/lib/apache-maven/apache-maven-3.0.4  
export M2=$M2_HOME/bin  
export PATH=$M2:$PATH  

It is desirable to set these variable durable. You can add them to your bash .profile script by executing following lines at once.

echo "  
export M2HOME=/usr/lib/apache-maven/apache-maven-3.0.4  
export M2=$M2HOME/bin  
export PATH=$M2:$PATH " >> ~/.profile  

Since we added maven to path, maven can be downloaded form every place in the system.

mvn --version  

Practically maven is now well preconfigured per default and suitable for most developers out of the box.

Additional Configuration

However personally i like to control some configuration. Basic configuration is done in settings.xml file. There are two locations where a settings.xml file may live:

  • The Maven install: $M2_HOME/conf/settings.xml
  • A user's install: ${user.home}/.m2/settings.xml

If both files exists, their contents gets merged, with the user-specific settings.xml being dominant.

Repository location

I prefer to set path of the repository location manually.



Here example of proxy configuration


Repository Mirror

It's possible to replace default repositories or some of them.Many organisation maintain their own repositories and you can link to them.

  <name>Maven Proxy</name>

Read more on mirroring details.