• How to Install Maven on Windows

    Maven is a Java build tool, JRE is not sufficient so you must have JDK installed in your system when installing maven on windows.

    1. Download Maven

    First, download the latest stable maven from maven.apache.org/download.cgi . Download the binary zip version of maven.

    Next, unzip files to wherever you want to store maven. In this post, we assume that you extract maven folder in C:\ which means it should be in C:\apache-maven-3.2.1, 3.2.1 is the maven version.

    2.Adding Environment Variables

    On Start Menu, type, “Edit the System Environment Variables” and hit enter. Click Environment Variables, and a dialog should open:

    environment variables

    On System variables, make sure you have JAVA_HOME set in your variables. If JAVA_HOME was not set, then add this by clicking New. In Variable name field, add JAVA_HOME and in Variable value, paste the location of your Java JDK location eg. C:\Program Files\Java\jdk1.8.0 . Click OK.


    Next, add Maven variables. First, add M2_HOME variable. On the same Environment Variables dialog, click again the New button. In Variable name field, add M2_HOME and in Variable value field, paste the location to where you unzip maven, in our case, it is in C:\apache-maven-3.2.1 . Click OK.

    m2 home

    Then also add M2 variable. Click again new and add M2 with the value %M2_HOME%\bin 


    Lastly, add edit the Path variables. Find Path in System variables and click edit. In variable value, append (semicolon) to the last line if not set, then add %JAVA_HOME%\bin; if JAVA_HOME is not existed. Next, also append %M2%;
    so your Path value should be look like this:

    path variable

    Click OK for the two dialog boxes to close.

    3. Testing Maven

    To test maven on windows, open command prompt by typing cmd on Start menu. Check first if Java Home was successfully installed in the system. In cmd, type java -version and your java version should be printed.

    java version

    Next, test your maven by typing mvn -version  or mvn –version . It should print your maven version

    maven version

    That’s it! You have successfully installed maven on windows.

    Related Post