How to install Maven on Windows

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.

How to install Maven on Windows
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.

How to install Maven on Windows

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

How to install Maven on Windows
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

How to install Maven on Windows

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

How to install Maven on Windows

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

How to install Maven on Windows

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

How to install Maven on Windows

5. Verification

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


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

C:Usersmkyong>echo %MAVEN_HOME%
C:optapache-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

原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/262645.html

(0)
上一篇 2022年5月27日
下一篇 2022年5月27日

相关推荐

发表回复

登录后才能评论