Monday, April 14, 2014

How to install Maven on Windows

Maven is a build and dependency management tool for java based application development.

It is not installed as a windows service. It is just configured with the windows environment variables. You just need to download the Maven binary zip file, extract it and configure the Windows environment variables.

The Windows Environment Variables are accessed from this location:

Click on Windows 'Start' button  >  Right-click on 'Computer'  >  Properties  >  Advanced system setting  >  Environment Variables


1. Set the JAVA_HOME system variable

Make sure the JDK is installed and "JAVA_HOME" system variable is present in the Windows environment variables. This should have the path to the jdk folder.

2. Download Maven

Download Maven from the Apache Maven download page. Choose a version and pick a binary distribution (e.g.;

3. Extract Maven 

Extract the zip file to a folder and make note of the directory path.

4. Set the M2_HOME system variable

Add the M2_HOME system variable and it should point to the Maven folder. Other people use MAVEN_HOME as the variable name but the maven installation instructions (at least as of version 3.2.1) specifically instructs to use M2_HOME as the variable name. One reason may be that M2_HOME is also the variable name used in the maven batch file (mvn.bat). Go open the batch file (found in the bin folder) and see.

5. Update the PATH system variable with the path to Maven's bin folder

Edit the Path system variable and add the entry " %M2_HOME%\bin " to point the Path variable to Maven's bin folder. This setting will allow you to run maven's command anywhere.

Click 'OK' to apply the new settings.

6. Verify your Maven installation is working

Open a new command prompt and type "mvn --version".

C:\Users\Eric>mvn --version
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T09:37:52-08:00)
Maven home: C:\_java\apache-maven-3.2.1
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: C:\Program Files\jdk1.7.0_51\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

You should get a response similar to this to indicate a successful installation of Maven.

No comments:

Post a Comment