Maven – Installation

Pre-requisites
1. Java SDK 1.5 or above






Windows Installation
1. Download the .zip at the Apache Maven Official site

2. Extract the folder (Example: C:\Program Files\Apache Software Foundation\apache-maven-2.2.1)

3. Add the following Windows Environmental Variable

  • M2_HOME – C:\Program Files\Apache Software Foundation\apache-maven-2.2.1
  • M2 – %M2_HOME%\bin

4. Also append the %M2% in PATH

  • PATH – …;%M2%

5. Open command prompt and type mvn -version to verify the installation






Linux Installation
1. Download the .tar.gz at the Apache Maven Official site

2. Extract the folder (Example: /usr/local/apache-maven-2.2.1)

3. Run the following command to configure the Environmental Variable

export M2_HOME=/usr/local/apache-maven-2.2.1
export M2=$M2_HOME/bin
export PATH=PATH=$M2:$PATH

4. Open command prompt and type mvn -version to verify the installation

* For Linux Installation, u can use apt-get install maven2 if u are using Ubuntu. But remember to verified the Environmental Variable after the installation.






Local Users Configuration
After u have tried the mvn commands, a folder .m2 is created in the user home folder.

  • Windows – C:\Users\ykyuen\.m2
  • Linux – \home\ykyuen\.m2

Now, create a repository folder at there as well as copy the settings.xml from the M2_HOME to .m2 which is now your own maven configuration file.

The minimum mandatory setting is the local user repository. So add the following line in the settings.xml

<localRepository>/home/ykyuen/.m2/repository</localRepository>

This repository will stored all the dependencies where you download from the maven repository.

Please note that the only difference between those 2 settings.xml is that the one at the user home folder will override the one at M2_HOME. So for any global setting which u want to apply it to all users, edit the one at M2_HOME.

That’s all =)

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.