How to install Maven on Windows

To install Apache Maven on Windows, you just need to download the Maven’s zip file, and Unzip it to the directory you wish to install, and configure the Windows environment variables.

Tools Used :

  1. JDK 1.7
  2. Maven 3.2.2
  3. Windows 8
Note
Maven 3.2 requires JDK 1.6 or above, while Maven 3.0/3.1 requires JDK 1.5 or above

1. JDK and JAVA_HOME

Make sure JDK is installed, and “JAVA_HOME” variable is added as Windows environment variable.

install-maven-on-windows-1

2. Download Apache Maven

Visit Maven official website, download the Maven zip file, for example : apache-maven-3.2.2-bin.zip. Unzip it to the folder you want to install Maven.

Assume you unzip to this folder – C:\Program Files\Apache\maven

install-maven-on-windows-2
Note
That’s all, just folders and files, installation is NOT required.

3. Add M2_HOME and MAVEN_HOME

Add both M2_HOME and MAVEN_HOME variables in the Windows environment, and point it to your Maven folder.

install-maven-on-windows-3
M2_HOME or MAVEN_HOME
Maven document said add M2_HOME only, but some programs still reference Maven folder with MAVEN_HOME, so, it’s safer to add both.

4. Add To PATH

Update PATH variable, append Maven bin folder – %M2_HOME%\bin, so that you can run the Maven’s command everywhere.

install-maven-on-windows-4

5. Verification

Done, to verify it, run mvn –version in the command prompt.


C:\Users\mkyong>mvn -version
Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T21:51:42+08:00)
Maven home: C:\Program Files\Apache\maven
Java version: 1.7.0_65, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_65\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "windows"
C:\Users\mkyong>

If you see a similar message, means the Apache Maven is installed successfully on Windows.

About the Author

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

Comments

Leave a Reply

avatar
newest oldest most voted
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.

Kishor Kumar
Guest
Kishor Kumar

Can you explain more how did u add mvn env variable directing to bin . Cause my mvn cmd is not recognised even after adding mvn variable

sharmi
Guest
sharmi

Adding the variable directing to bin under Path is given above. And, then to run the mvn command successfully, you’ll have to first navigate to the folder where maven folder has been placed.

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

Priya
Guest
Priya

Even i faced the same problem. Create a ‘mvn’ env variable it will work fine.

Guna
Guest
Guna

I had the same issue. I restarted cmd, then tried again ‘mvn -version’. It worked.

Rupali
Guest
Rupali

thanks a lot @Guna

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.

Manikanta Kumar
Guest
Manikanta Kumar

You are correct. Binary.zip should be downloaded.

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…

Ahmad Hamdan
Guest
Ahmad Hamdan

JAVA_HOME variable should not contain /bin directory in its path
(example that worked for me: JAVA_HOME=C:\Program Files\Java\jdk1.7.0_76)

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!

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

Agyeya Gupta
Guest
Agyeya Gupta

mvn –version
That’s with 2 hyphens

Que
Guest
Que

Thank you, I had to run CMD as administrator though

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 »
Mayuresh Trivedi
Guest
Mayuresh Trivedi

Use mvn -v

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!

VeaceslavKunitki
Guest
VeaceslavKunitki

mvn — version
not mvn -version
double minuses

William M
Guest
William M

thanks a lot

Kidus M.Tekeste
Guest
Kidus M.Tekeste

Thanks man!
very clear steps!

David
Guest
David

thanks worked great

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

this article work for me on windows 10, thanks.

Alia
Guest
Alia

This post helped me. Thanks for sharing.

kyler
Guest
kyler

I like squirrels

kyler
Guest
kyler

china numbah 1!!!!

Ashutosh Kushwaha
Guest
Ashutosh Kushwaha

Helpful, thanks buddy

Alde
Guest
Alde

I didnt add ‘%M2_HOME%bin’ to the system environment variables! Thanks for this.

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 »
Reynaldo Pakpahan
Guest
Reynaldo Pakpahan

thanks for tutorial, it’s really great and easy to follow ur lead, thanks!

zahra khoobi
Guest
zahra khoobi

thanks!

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.

sravan
Guest
sravan

When i “mvn -version” getting the following result.
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T14:39:06-05:00)
Maven home: C:Program Filesapache-maven-3.5.0bin..
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: C:Program FilesJavajdk1.8.0_144jre
Default locale: en_US, platform encoding: Cp1252
OS name: “windows 10”, version: “10.0”, arch: “amd64”, family: “windows”
‘cmd’ is not recognized as an internal or external command,
operable program or batch file.

cmd’ is not recognized as an internal or external command,
operable program or batch file.

raj
Guest
raj

May be a system restart will help. I got the same.

Reshmi
Guest
Reshmi

Thank you. It helped.

Kelton
Guest
Kelton

Hi.. Thanks a lot for your help. Very simple and accurate. Worked fine for me on Windows 7.

teoman
Guest
teoman

Amazing tutorial, thanks a lot!

Riski
Guest
Riski

thanks a lot

farha
Guest
farha

Thanks!!

Florian Thiery
Guest
Florian Thiery

perfect, thx!