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.

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\mkyong>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\mkyong>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

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
334 Comment threads
80 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
366 Comment authors
Kavya bhatAhmedArhamImran AnsariSimon Recent comment authors
newest oldest most voted
mai magdy
Guest
mai magdy

i have an error while running mvn -version saying : notrecognized command as external or internal command ,knowing that i have added MAVEN_HOME IN the system variables …so any idea how to fix it ??…thanks

Kunal Gautam
Guest
Kunal Gautam

Also, had to add env variable with name ‘mvn’ and direct it to the bin folder, and then it was smooth sailing for me.

Sahaj Arora
Guest
Sahaj Arora

It didn’t work for me.
To make it work, In Path variable, instead of adding %M2_HOME%bin, I added C:Program FilesApachemavenbin.
And voila! it worked!

Paresh Chavhan
Guest
Paresh Chavhan

Hi
Actually, i am facing the problem when type command prompt mvn -version the error shows like that
C:Usersjkj>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

But Java Home is already set and when enter command prompt like Java -Version
C:Usersjkj>java -version
java version “1.8.0_161”
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
so how to overcome this problem plz guide me asap…

Yuva Yuvi
Guest
Yuva Yuvi

This post helped a lot. If anyone have the following issue “Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher”. Download Binary zip archive files, Instead of downloading Source zip archives.

Lisa Kristinardottir
Guest
Lisa Kristinardottir

Hi all: This works in Windows 10 latest with all updates as of Dec. 22, 2017. Unzip maven zip file to any folder. e..g c:Program Files is recommended for Windows 10. Like into c:Program FilesApacheMaven like I gave here. Every setup given here is fine. Just also MAKE SURE that you do the mvn variable setting (in BOTH user and system sections to make sure it catches it everywhere, to allow you to run Maven everywhere) and and in the path, i.e. %mvn%bin. Close command terminal window and reopen a new one. run: mvn -v or mvn –version Output will… Read more »

Raj Kumar Kundu
Guest
Raj Kumar Kundu

mvn –version did not work for me. It was giving “BUILD FAILURE”. I had to use mvn –version (note double dash). Please note that I am using following environment:
Windows 7
Maven 3.3.9
Java 7

Que
Guest
Que

Thank you, I had to run CMD as administrator though

Deep Xavier
Guest
Deep Xavier

I can’t run mvn command in Git Bash but works just fine in the Windows command prompt. I assume that this has to do with my user access rights which is not system administrator level. Any workaround on this one? Or any one experience the same situation and has resolve it. I’ve done everything I’ve found from the net for the possible solution but nothing works. BTW, I am running on a Windows 10 machine. Thanks.

Mayuresh Trivedi
Guest
Mayuresh Trivedi

Use mvn -v

César Peñate
Guest
César Peñate

this article work for me on windows 10, thanks.

VeaceslavKunitki
Guest
VeaceslavKunitki

mvn — version
not mvn -version
double minuses

junior
Guest
junior

This is the most accurate tutorial about setting up maven in Windows. Working fine in Windows 10. Just need to pay attention in every step. Thank you!

David
Guest
David

thanks worked great

Kidus M.Tekeste
Guest
Kidus M.Tekeste

Thanks man!
very clear steps!

Vikas
Guest
Vikas

While running command using mvn -version i got error. Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved. C:UsersVik>mvn __V Cannot find function ext-ms-win-cmd-util-l1-1-0.dll:CmdBatNotificationStub. is not a valid Win32 application. [INFO] Scanning for projects… [INFO] ———————————————————————— [INFO] BUILD FAILURE [INFO] ———————————————————————— [INFO] Total time: 0.100 s [INFO] Finished at: 2018-01-25T12:35:55+05:30 [INFO] Final Memory: 10M/109M [INFO] ———————————————————————— [ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:UsersVik). Please verify you invoked Maven from the correct directory. -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors,… Read more »

Ashutosh Kushwaha
Guest
Ashutosh Kushwaha

Helpful, thanks buddy

kyler
Guest
kyler

I like squirrels

Alia
Guest
Alia

This post helped me. Thanks for sharing.

William M
Guest
William M

thanks a lot

trackback
How to integrate between Apache Archiva and Maven | Maven

[…] How to install Maven in Windows or How to install Maven in Ubuntu […]

amr ali
Guest
amr ali

please
i did the steps and every thing is ok
but it does not show the lines :
Java home: C:\Program Files\Java\jdk1.6.0_13\jre
Default locale: en_US, platform encoding: Cp1252

please i need to know how to make it see java home.

trackback
Maven Tutorials | Tutorials

[…] Install Maven in Windows environment Article about how to install Maven in Windows environment. […]

Swastik
Guest
Swastik

Hi

Your tutorials are awesome.
Can you please start a new tutorials on EJB?

David
Guest
David

The following article is using Symbolic link to upgrade Maven version transparently using Windows 7 http://www.java-tutorial.ch/windows-systems/maven-installation-and-configuration-for-windows

Ashima
Guest
Ashima

I downloaded maven and already had jdk 1.6 installed on my system. But once I installed maven, it did show me the verification in the cmd prompt and the version, etc. But now when I tested my java version, it showed me 1.3 instead of 1.6.. Does anybody know why it is doing that? Any help is appreciated.
Thanks!

Ashima
Guest
Ashima

This is what it shows me…
C:\Documents and Settings\a500>java -version
java version “1.3.1_01”
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)

C:\Documents and Settings\a500>mvn –version
Apache Maven 2.2.1 (r801777; 2009-08-06 15:16:01-0400)
Java version: 1.6.0_26
Java home: C:\Program Files\Java\jdk1.6.0_26\jre
Default locale: en_US, platform encoding: Cp1252
OS name: “windows xp” version: “5.1” arch: “x86” Family: “windows”

Arul
Guest
Arul

In the image the maven home is “D:\maven” but in the text extract in “C:\apache-maven-2.2.1” . It may confuse the user. Please change

Alpesh
Guest
Alpesh

Very useful

Thanks for putting in,

Bikash
Guest
Bikash

Great Tutorial exact to point.