To install Apache Maven on Windows, you just need to download the Maven’s zip file, unzip it to a folder, and configure the Windows environment variables.

Tested with :

  1. JDK 10
  2. Maven 3.6
  3. Windows 10

Note

1 – Maven 3.3+ requires JDK 1.7+

2 – Maven 3.2 requires JDK 1.6+

3 – Maven 3.0/3.1 requires JDK 1.5+

1. JDK and JAVA_HOME

Make sure JDK is installed, and JAVA_HOME environment variable is configured.

Note

Please read this how to add JAVA_HOME on Windows 10

2. Download Apache Maven

2.1 Visit Maven official website, download the Maven zip file, for example : apache-maven-3.6.0-bin.zip.

2.2 Unzip it to a folder. In this article, we are using c:\opt\apache-maven-3.6.0

Note

That’s all, just download and unzip, installation is NOT required.

3. Add MAVEN_HOME system variable

Add a MAVEN_HOME system variables, and point it to the Maven folder.

3.1 Press Windows key, type adva and clicks on the View advanced system settings

3.2 In System Properties dialog, select Advanced tab and clicks on the Environment Variables... button.

3.3 In “Environment variables” dialog, System variables, Clicks on the New... button and add a MAVEN_HOME variable and point it to c:\opt\apache-maven-3.6.0

4. Add %MAVEN_HOME%\bin To PATH

In system variables, find PATH, clicks on the Edit... button. In “Edit environment variable” dialog, clicks on the New button and add this %MAVEN_HOME%\bin

5. Verification

Done, start a new command prompt, type mvn –version :

C:\Users\favtuts>mvn -version
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)
Maven home: C:\opt\apache-maven-3.6.0\bin\..
Java version: 10.0.1, vendor: Oracle Corporation, runtime: C:\opt\Java\jdk-10
Default locale: en_MY, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

C:\Users\favtuts>echo %MAVEN_HOME%
C:\opt\apache-maven-3.6.0

The Apache Maven is installed successfully on Windows.

6. FAQs

6.1 ‘mvn’ is not recognized as an internal or external command?

> mvn -version
'mvn' is not recognized as an internal or external command,
operable program or batch file.

Answer: Refer to Step 4, make sure the %MAVEN_HOME%\bin is added to the PATH system variable.

6.2 The JAVA_HOME environment variable is not defined correctly

> mvn -version
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE

Answer: Refer to Step 2, make sure JDK is installed and the JAVA_HOME system variable is configured.

References

  1. How to add JAVA_HOME on Windows 10

Leave a Reply

Your email address will not be published. Required fields are marked *