How to Install Maven on Windows

0
2

Introduction

To setup Maven 3.3 on Windows you will need to install JDK 1.7 or higher, download and extract the Maven 3.3 archive, and then configure some environment variables.

Install JDK 1.7 or higher

If you don’t already have Java 7 or higher installed, just Google “Oracle JDK download” and go to the Oracle JDK download site. Unless you have special requirements, I recommend downloading the 64 bit version of Java since Windows 7 and higher support 64 bit applications. Also I recommend just going with the highest version of Java. In this example it’s Java 8 update 74.

Now install the JDK. On Windows, 64 bit Java will be installed under C:/Program Files/Java. You may notice that there is C:/Program Files (x86). This is the directory that contains your 32 bit applications. Had you installed 32 bit Java you would find Java installed under C:/Program Files (x86)/Java.

Configure JAVA_HOME Environment Variable

Add the JAVA_HOME environment variable and set it to the installation path of the version of Java you installed. In this example it’s C:/Program Files/Java/jdk1.8.0_74.

environment_variables_JAVA_HOME

To confirm Java is installed just open up a Command window and type java -version.

java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)

Download and Extract Maven Archive

Go to the Apache Maven download site and download the Maven archive. In this example, I’ve downloaded the Maven 3.3.9 binary zip archive named apache-maven-3.3.9-bin.zip and extracted it to C:\Dev\apache-maven-3.3.9.

Edit Environment Variables

Configure M2_HOME Environment Variable

Add M2_HOME environment variable and set the value to the path where Maven was extracted. In this case it’s C:\Dev\apache-maven-3.3.9.

environment_variables_M2_HOME

Configure Path Environment Variable

Edit the Path environment variable and add %M2_HOME%\bin. Be careful not to miss the semi-colon delimiter. The bin folder needs to be added to the Path environment variable so that mvn can be executed in a command window.

environment_variables_Path

environment_variables_maven_path

Verify Maven Version in Command Window

Open up a command window by typing cmd.exe on the Start Menu or right clicking on a folder while holding down Shift and selecting Open command window here.

Type mvn -version. Maven should display its version. If it does then you’ve successfully setup Apache Maven.

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
Maven home: C:\Dev\apache-maven-3.3.9
Java version: 1.8.0_74, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_74\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"

LEAVE A REPLY

Please enter your comment!
Please enter your name here