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

474 comments on “How to install Maven on Windows

  1. Another resource did not show me the “Path” step, so it did not work! With your step by step instruction it worked! Thx a lot 🙂

  2. After verifying the correctly installation of Maven by running this command in the cmd prompt in Windows: mvn -version

    I am still getting this error despite I made sure all is in place:

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

  3. When unzipping the maven package, sometimes a sub-folder with same name is created (C:\opt\apache-maven-3.8.6\apache-maven-3.8.6). Same has happened in my case and was ended up with error – “‘mvn’ is not recognized as an internal or external command“. Please verify the same going to the path in your system and add the same exact path in Env. variables > System variables > New > Variable name: ‘MAVEN_HOME’; Variable value: ‘C:\opt\apache-maven-3.8.6\apache-maven-3.8.6’ > OK
    Restart the Command Prompt and check ‘mvn -version’. This worked for me.

  4. i have an error while running mvn -version: It is saying like not recognized command as external and internal command………so some one can fix this prblm…………..

  5. i am facing this Error
    mvn -version
    The JAVA_HOME environment variable is not defined correctly,
    this environment variable is needed to run this program.

  6. I’m getting error “The system cannot find the path specified.”. Kindly share your suggestion

    C:\Users\pdurg>mvn -version
    Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
    Maven home: C:\Users\pdurg\Downloads\apache-maven-3.8.1-bin\apache-maven-3.8.1\bin\..
    Java version: 16.0.1, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-16.0.1
    Default locale: en_US, platform encoding: Cp1252
    OS name: “windows 10”, version: “10.0”, arch: “amd64”, family: “windows”
    The system cannot find the path specified.

  7. C:\Windows\system32> mvn -version
    ‘mvn’ não é reconhecido como um comando interno
    ou externo, um programa operável ou um arquivo em lotes.

  8. Wow, finally some straight-forward steps in how to do this! You wouldn’t believe how horrible most of the web dev resources I find via search engine. 👎🏼 This is the third time I’ve used your website to get “stuff done”. Thank you for this resource! ♥²

  9. While doing the 4th step I am facing problem
    I find the Path and after clicking on edit, I am not getting the window as you got the window with options like (new, browse, delete,moveup……) Just am getting the window with variable name and variable value. Die to these problem I am not able to do the fourth step, So can you please help me to resolve this issue.

  10. Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
    Maven home: C:\Program Files (x86)\apache-maven-3.6.3\bin\..
    Java version: 14.0.2, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-14.0.2
    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.

  11. Hi mkyong, mvn -version works fine for me but i have encountered the following issue in my laptop which probably due to firewall setting? Any idea?

    D:\Workspace\test\maven\sample-project-maven-master>mvn clean install
    [INFO] Scanning for projects…
    [INFO]
    [INFO] ——————————-
    [INFO] Building sample-project-maven 1.0.0-SNAPSHOT
    [INFO] ——————————–[ jar ]———————————
    Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 4.195 s
    [INFO] Finished at: 2020-07-12T18:49:51+08:00
    [INFO] ————————————————————————
    [ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

  12. Thanks for this, incredibly useful. Totally new to Spring, started doing the hello world tutorial and they leave you hanging. They tell you to install AdoptOpenJDK but then assume you know everthing else!

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

    Answer: click OK button in environment variables tab before run cmd command:)

  14. Hi,I have done the steps which is mentioned above but still im getting the same error.Im working on windows 10. So anyone have the solutions for this ? Kindly let me know .

  15. it did not worked for me so i added the original maven bin path to the System Variable Path (like c:\program..\maven-3…\bin)
    It worked for me.

  16. Hello,

    Please add M2_HOME in environment variable and congigure in path like : %M2_HOME%\bin will solve issue for maven version 3.6.2

    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

  17. C:\WINDOWS\system32>mvn ?version
    Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T08:06:16-07:00)
    Maven home: D:\apache-maven-3.6.2\bin\..
    Java version: 1.8.0_211, vendor: Oracle Corporation, runtime: C:\Program Files (x86)\Java\jdk1.8.0_211\jre
    Default locale: en_IN, platform encoding: Cp1252
    OS name: “windows 10”, version: “10.0”, arch: “x86”, family: “windows”

    C:\Windows\System32>
    worked for me…run cmd as a administrator it will work for all of you.

  18. Hi,

    I don’t need to install in my system. we need to raise a ticket, then they will install whatever we need. I checked in command prompt after the completion of installation

    C:\Users\u590023>mvn -version

    Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T11:41:47-05:00)

    Maven home: C:\Program Files (x86)\Apache\Maven339\bin\..

    Java version: 1.8.0_212, vendor: Oracle Corporation

    Java home: C:\Program Files\Java\jdk8\jre

    Default locale: en_US, platform encoding: Cp1252

    OS name: “windows 10”, version: “10.0”, arch: “amd64”, family: “dos”

    Could you please check whether any issue is there. Because my anyPointStudio is not able to build the application.

    Note:- java home is pointed to jre, but not jdk. Is there any issue here.

    Advanced Thanks

  19. Issue while providing maven bin path
    When i am double clicking on my path then instead of pop up where i can add new path, that path is getting edited (which already has jdk path). so its like if i paste that maven path then jdk path will get removed. Basically i am not able to add 2 links for same “Path” environmental variable under section system variable. But under user variable i am able to do so for path.

    Please guide, i am stuck at this step

  20. Thanks. I had downloaded the wrong distribution. Also, for the JDK I had to echo %JAVA_HOME%. Some how “:” was part of the string.

  21. Hi Pankaj sir,
    I have encountered the issue while executing the command mvn clean package on git bash.
    bash: mvn: command not found

    Can you help me.

    Thanks in advance.

  22. Error: JAVA_HOME is set to an invalid directory.
    JAVA_HOME = “C:\Program Files\Java\jdk1.8.0_172\bin”
    Please set the JAVA_HOME variable in your environment to match the
    location of your Java installation.

    i am getting this error while setting path for maven any idea how to solve it .

    i remove bin from java and try still not able to solve it

  23. Careful with which java version you are using!
    Tried with latest JDK (jdk-10.0.2_windows-x64_bin.exe), failed.
    Tried again with jdk-8u181-windows-x64.exe, worked.

  24. Getting the following error

    C:\Users\a0>mvn –version
    Exception in thread “main” java.lang.UnsupportedClassVersionError: org/apache/ma
    ven/cli/MavenCli : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
    1)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(Cl
    assRealm.java:401)

  25. For anyone who has completely followed the steps outlined in the guide, and still face the message:
    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
    It may be due to the whitespace in the folder you’ve stored the JDK in.
    I used the command line: setx -m JAVA_HOME “C:\Progra~1\Java\jdk-10.0.1”
    Please feel free to use a variant of that specific to your version or location and see if it helps.

    Heads up, I’m on Windows 7.

  26. 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…

    1. 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)

      1. I had the same error problem just this week of July 2021, I found the problem was in the syntax above, “mvn -v”, was the problem. So I tried “mvn –v”, with double hyphens on Microsoft Windows 10, and this was the cure for the problem. Also in Environment variables I set the variable as “MAVEN_HOME = C:\Program Files\apache-maven\apache-maven-3.8.1\ ” …make sure to end with a backslash on MSWindows, MAVEN_HOME needs to look for the whole Environment and not the “bin”, such as “%MAVEN_HOME%\bin” .. The path will then relat to the path set in the variable setting url . Also, DO include the “bin” url when setting the PATH. You should also have JAVA_HOME set up the same way.When I did this then, … everything worked as it should. Now running the command line syntax for versions of Java_Home & Maven_Home should work.

  27. 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!

  28. 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, re-run Maven with the -e swit
    ch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please rea
    d the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProject
    Exception
    Cannot find function ext-ms-win-cmd-util-l1-1-0.dll:CmdBatNotificationStub.
    is not a valid Win32 application.

  29. 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 look like this:
    Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T02:58:13-05:00)
    Maven home: C:Program FilesApachemavenapache-maven-3.5.2-binapache-maven-3.5.2bin..
    Java version: 1.8.0_131, vendor: Oracle Corporation
    Java home: C:Program Files (x86)Javajdk1.8.0_131jre
    Default locale: en_US, platform encoding: Cp1252
    OS name: “windows 10”, version: “10.0”, arch: “x86”, family: “windows”
    ‘cmd’ is not recognized as an internal or external command,
    operable program or batch file.

    I also ran the mvn command:
    e..g.
    mvn clean install -Dmaven.test.skip=true

    and it built my project without any errors.

    Please Note:
    Ignore the last part it’s a false positive message, meaning nothing in this context:
    i.e.
    ….
    ….
    ‘cmd’ is not recognized as an internal or external command,
    operable program or batch file.

    Cheers. Happy Holidays All.

  30. Hi,

    Is step #3 (Add M2_HOME and MAVEN_HOME) necessary? I tried skipping this step and adding the path directly to Path variable like this – C:apacheapache-maven-3.5.2bin and it worked.

    What is the difference with directly adding to Path variable and step #3?

    Thanks.

  31. 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.

  32. 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.

  33. 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.

  34. 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!

  35. THANKS!! This is the olny way that works for me with Windows 10 64bits. The normal install doesn’t worked :/

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

    1. 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

      1. 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.

      2. One special note. If you add MAVEN_HOME as a User defined variable and you do not add this as a SYSTEM variable then the Path will NOT see it. You need to add this as a SYSTEM Variable then the Path reference will see the MAVEN_HOME.
        “User Var: MAVEN_HOME = C:\apache-maven-3.5.4 SYSTEM Var: MAVEN_HOME = C:\apache-maven-3.5.4 , AND I added this to Path = %MAVEN_HOME%\bin; ”

        I added the ” ” in order for this forums settings to NOT strip out the “/”

        Note: JAVA_HOME needs to be set correctly as well to the location your JDK or JRE has been installed.

      1. I added it more than once, it doesn’t work. it’s getting frustrating, I have been trying to accomplish this simple task for 2 days now.

  37. i am getting following erro messages

    Microsoft Windows [Version 6.1.7600]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:Usersswami>mvn -version
    Exception in thread “main” java.lang.UnsupportedClassVersionError: org/apache/ma
    ven/cli/MavenCli : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(Cl
    assRealm.java:401)
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(
    SelfFirstStrategy.java:42)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadCl
    ass(ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm
    .java:254)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm
    .java:239)
    at org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(Launch
    er.java:144)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
    cher.java:266)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
    a:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
    uncher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
    356)

    C:Usersswami>

  38. Great!
    This article the only of its kind on the Internet (including the Maven official site), which led me to a successful Maven installation.
    Thank you so much!

  39. Mykong, thanks a lot, I have a question:

    Why pdfbox.jar is not transitively inherited in upper level hierarchy…?

    There’s a pom.xml of project B, that has mentioned in it:

    org.apache.pdfbox
    pdfbox-app

    org.apache.pdfbox
    xmpbox

    Now, project A has dependency of project B.
    Project A’s dependency hierarchy show’s that pdfbox-app and xmpbox has been transitively inherited from project B.

    BUT,

    On changing the pdfbox-app to pdfbox (thus Project B’s pom.xml looks like):

    org.apache.pdfbox
    pdfbox

    org.apache.pdfbox
    xmpbox

    On doing this , the upper level project A’s pom.xml doesn’t show pdfbox or xmpbox as it’s transitive dependencies.
    Why is pdfbox not inherited by the upper level project A?
    Please help.

  40. thanks for this! one thing, in command please add one more “-“. I believe it may have missed during formatting of HTML

    “mvn –version”

  41. 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

  42. On the latest version of maven (3.3.9), the command mvn -version doesn’t work. Use mvn -v instead.

    1. I followed all the steps but mvn or maven doesn’t seem to work 🙁 I added M2_HOME and MAVEN_HOME under system variables.

      1. Please check JAVA_HOME is set or not and if set then whether till the jdk only it should be and not till bin .Coz I also faced the same issue and checked there was problem with the JAVA_HOME set so I suggested .

  43. When I did the exact above steps, I got an error – M2_HOME is set to an invalid directory, whereas everything was fine. M2_HOME and MAVEN_HOME was set to the same directory where I had unzipped maven 3.3.9
    But, when I updated the path, removed ‘%M2_HOME%bin’ and changed it to my maven directory – ‘C:eclipseapache-maven-3.3.9bin’, it worked perfectly fine.

    Thanks!

  44. mvn -version
    then i am getting following output but that output window is disappearing…..
    C:Usersmkyong>mvn -version
    Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T21:51:42+08:00)
    Maven home: C:Program FilesApachemaven
    Java version: 1.7.0_65, vendor: Oracle Corporation
    Java home: C:Program FilesJavajdk1.7.0_65jre
    Default locale: en_US, platform encoding: Cp1252
    OS name: “windows 8.1”, version: “6.3”, arch: “amd64”, family: “dos”

    the above output i captured through printscreen option to analyze what exactly output is coming whether my maven is installed correctly or not?

  45. I cannot find the bin directory in maven and i thinks thats why i get error message “‘mvn’ is not recognized as an internal or external command,operable program or batch file.”

  46. Help I get

    [ERROR] The goal you specified requires a project to execute but there is no POM
    in this directory (C:WindowsSystem32). Please verify you invoked Maven from t
    he correct directory. -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
    ch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please rea
    d the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProject
    Exception

    C:WindowsSystem32>

  47. can i install maven related everything in other drive.
    how i do it ??
    If i do it then it will not effect in future means it will not generate problem in future

  48. Hi,
    C:Windowssystem32>mvn -v
    Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T22:59:23+05:30)
    Maven home: D:automationapache-maven-3.2.5
    Java version: 1.8.0_45, vendor: Oracle Corporation
    Java home: C:Program FilesJavajdk1.8.0_45jre
    Default locale: en_US, platform encoding: Cp1252
    OS name: “windows 7”, version: “6.1”, arch: “amd64”, family: “dos”
    ** The system cannot find the path specified.**
    i had above error “The system cannot find the path specified” after configuring maven in windows 7
    Please help

  49. Hi,
    Any one help me in this.
    I have installed maven…and configured my project folders into maven.
    But i am facing a problem is that build failure..
    error is..could not resolve the dependencies…

  50. Thank you ! I had a problem with “exception in thread main unsuported
    major version” but i edited JAVA_HOME variable to the recent version (jr8) and
    just worked.

    1. Thanks for sharing.I was getting the same error. I was using java 1.6 and maven 3.3.3. So i installed earlier version of maven – maven3.0.5. It worked. Either you upgrade to java 1.8 or downgrade maven version

  51. I’m having a error.
    The goal you specified requires a project to execute but there is no POM in this directory (C:WindowsSystem32). Please verify you invoked Maven from the correct directory.

    What I have to do?
    Thanks

  52. Let’s assume that I am not 100% idiot. What else can I do to bind maven on Windows 8?
    ’cause this doesn’t work for me. Maven variables (MAVEN/M2/M2_HOME/MAVEN_HOME) have already been to user and system variables, simultaneously and one per each, both names in user and system parts; dirs were copied multiple times by copy/paste from the actual Windows GUI…
    any other ideas how to make this work properly?

  53. 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

    1. Its working with directly adding the path , rather than setting MAVEN_HOME and then giving path in Environment varibale >> System variable > path

      1. Thank you. This is the only thing that worked for me after some 4-5 hours of just finding a solution
        anyone who still has a problem. After you do all the above things or anything you found on stackoverflow and still not working do this

        Environment Vars => System Variables => path => Edit => New => C:\opt\apache-maven-3.6.2\bin

        Done. Worked for me

  54. Perfect instructions. Everyone has a different opinion, but at least for me, this is the most thorough, precise, and grammatically correct set of instructions I have ever read.

    Bravo & thanks

    1. the reason is that You installed the src version of maven. installed the
      apache-maven-{version}-bin.zip or apache-maven-{version}-bin.tar.gz.
      Then maven will get installed properly.
      [Source: Banu’s comment above]

  55. Hi I created a maven project in windows.Actually for the first time it downloaded all my dependency what ever i want.Again if i created another project.Then dependency should comes from m2 right.Instead it downloaded again from maven repo can you help me to resolve this.Thanks.

  56. Your tutorials are always my first source of research now a days, as the quality is as good as it gets. Thank you very much mkyong!!

    With regard to this tutorial, just one correction i spotted … To verify that maven is installed, you run mvn –version, in the tutorial it says mvn -version (one dash) apparently it worked for you, but it didn´t for me. In another tutorial i saw it with two dashes, and by doing so, it worked.

  57. you are my heroe for the week!
    i don’t know why this works with the variables declared on it’s own first and not set directly in de %path%, but..
    it works!
    thank you so, so much

  58. That’s all I nedeed! When I read “Once you have downloaded the zip file, unzip it to your computer. Then add the bin folder to your path.” into the oficial site I didn’t understand what I have to do for add the bin folder on my path…thank you so much!

  59. An alternative is to install using chocolatey.org.

    1. Install chocolatey
    2. run: cinst jdk8
    3. run: cinst maven

    Voila!

  60. Setting MAVEN_HOME as system variable instead of user Variable will resolve “mvn not recognized as an internal or external command”

  61. I have referred a lot of your blogs for code..they are extremely helpful and well structured..they state all the information from the start to end and not at all confusing.great work.keep posting ..

  62. Not getting the text as follows

    Apache Maven 2.2.1 (r801777; 2009-08-07 03:16:01+0800)
    Java version: 1.6.0_13
    Java home: C:Program FilesJavajdk1.6.0_13jre
    Default locale: en_US, platform encoding: Cp1252
    OS name: “windows xp” version: “5.1” arch: “x86” Family: “windows”

    Kept maven in D:mavenapache-maven-3.1.1 folder. Also, all my programs are saved in D: as this is my Program Files path

  63. If you are getting errors running mvn -version in command prompt (bad command or file name..etc) then you should open command prompt as administrator. (right click on command prompt icon and select run as admin)
    Solved it for me.
    Thanks Mkyong! I refer to your code sometimes while teaching my students J2EE.

      1. mvn -version
        then i am getting following output but that output window is disappearing…..
        the
        following output i captured through printscreen option to analyze what
        exactly output is coming whether my maven is installed correctly or not?

        C:Usersmkyong>mvn -version
        Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T21:51:42+08:00)
        Maven home: C:Program FilesApachemaven
        Java version: 1.7.0_65, vendor: Oracle Corporation
        Java home: C:Program FilesJavajdk1.7.0_65jre
        Default locale: en_US, platform encoding: Cp1252
        OS name: “windows 8.1”, version: “6.3”, arch: “amd64”, family: “dos”

  64. mvn -version did not work for me so i tried to run mvn -v..and it worked for me…the mvn -version command scan and looks for a pom file if run..

  65. Error: JAVA_HOME is not defined correctly.
    We cannot execute /cygdrive/c/Program Files/Java/jdk1.7.0_10;C:/Program Files/Java/jdk1.7.0_10/bin;/bin/java

    whyyyyyyyyyyyyy????

    i do all steps exactly but ..

  66. error could not find or load main class org.codehaus.plexus.classworlds.launcher.launcher

    I am getting this error when i run in cmd prompt

    >mvn -version

    I have set the MAVEN_HOME and JAVA_HOME (system variable) and user variables path

    1. It got it fixed.. the reason is that i installed the src version of maven. installed the
      apache-maven-{version}-bin.zip or apache-maven-{version}-bin.tar.gz.
      Then maven got installed properly

  67. Hey Mkyong,
    Thanks for the article, very useful information. However, for months this article has been up, yet you’ve not replied to one of the questions that people have posted on here. Shame that.
    But don’t panic!! I’ve done that for you!
    Cheers

    1. Yes, you need to open a software. Though I’m not sure if you’re joking or not.
      However, in Win7 click Start then type in environment. Select the option that appears saying “Edit the system environment variables”. Then click the nice button that says “Environment variables…”

  68. I’m getting this error at start up: An error occurred while filtering resources Employee line 1 Maven Configuration Problem
    Please help.

  69. I followed this page’s instructions, but when I type in mvn -version, I get the classic:

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

    When looking at my environment variables, I have:

    User variables for jameswe
    TEMP %USERPROFILE%\AppData\Local\Temp
    TEMP %USERPROFILE%\AppData\Local\Temp

    System variables:
    Among many other things
    JAVA_HOME C:\Program Files\Java\jdk1.7.0_25
    MAVEN_HOME C:\Users\jameswe\Maven
    Path %SystemRoot%\system32;…lots of stuff…;%MAVEN_HOME%\bin

    What’s going wrong here? I just restarted, so that’s not it. What’s wrong with my values?

    Thanks!

  70. Hello Sir,
    I have set my env variables as:
    JAVA_HOME=C:\Program Files\Java\jdk1.6.0_43
    MAVEN_HOME=D:\Softwares\apache-maven-3.0.4
    PATH=%PATH%;D:\Softwares\apache-maven-3.0.4\bin

    In cmd prompt if I try mvn -version I get,
    C:\Documents and Settings\xyz>mvn -version
    Usage: java [-options] class [args…]
    (to execute a class)
    or java [-options] -jar jarfile [args…]
    (to execute a jar file)

    where options include:
    -client to select the “client” VM
    -server to select the “server” VM
    -hotspot is a synonym for the “client” VM [deprecated]
    The default VM is client.

    -cp
    -classpath
    A ; separated list of directories, JAR archives,
    and ZIP archives to search for class files.
    -D=
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -version:
    require the specified version to run
    -showversion print product version and continue
    -jre-restrict-search | -jre-no-restrict-search
    include/exclude user private JREs in the version search
    -? -help print this help message
    -X print help on non-standard options
    -ea[:…|:]
    -enableassertions[:…|:]
    enable assertions
    -da[:…|:]
    -disableassertions[:…|:]
    disable assertions
    -esa | -enablesystemassertions
    enable system assertions
    -dsa | -disablesystemassertions
    disable system assertions
    -agentlib:[=]
    load native agent library , e.g. -agentlib:hprof
    see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:[=]
    load native agent library by full pathname
    -javaagent:[=]
    load Java programming language agent, see java.lang.instrument

    -splash:
    show splash screen with specified image

    Please help me Sir..I’m not sure what I’m missing here.

  71. I think this is among the most important info for me.
    And i’m glad reading your article. But wanna remark on few general things, The web site style is ideal, the articles is really great : D. Good job, cheers

  72. hello Mkyong , I tried your maven installation process, but when i check it using
    “mvn -version” command that time it show error that

    —–> c:\Document and Settings\nitesh>mcn -version
    ‘mvn’ is not recognized as an internal or external command,
    operable program or batch file.

  73. Pretty section of content. I just stumbled upon your weblog and
    in accession capital to assert that I acquire in fact enjoyed account your blog posts.

    Any way I will be subscribing to your augment and even I achievement you access consistently fast.

  74. This is a very good tutorial. It has saved me much headache. Thanks. to lengthen it a bit, maybe you could add screen-shots on how “system variables” are created. This will adequately help those who aren’t familiar with this. Thanks, once more!

  75. Hi mkyong and team,

    Sorry if i post the request on the wrong thread..but i need help on this:

    I am using CloudReport the GUI side which run on CloudSim simulator..
    I managed to add 4 data centers and 40 users….my request is:

    1.I want to customize everything,i mid bandwidth,connects,destinations etc how should i change the destination of customer to host?
    2.what are the units used on CloudReport simulator exampe starage are they in MB or bytes?
    3.before i was able to simulate 2 datacenters and 4 users but now i cant simulate 4 datacenters and 40 users..it says simulation interapted and i dont see on the log,can anyone help plz

    Thank you!

  76. For Windows 7 you should give M2_HOME instead of MAVEN_HOME.
    And also create a .m2 directory in the user profile. eg( C:\Users\jaseem\.m2 )

  77. Thank you very much. I have been trying to do this all night long until I got this post from you. I worked like waooo! This sight will be my learning platform from now on.
    Thank you MKYONG

  78. I tried all the steps…frm A -Z….
    stil m nt able to get my maven wrk successfully.
    finaly it says dt ‘mvn’ is nt a recognized command.
    plz help…

    1. Hi Anshul

      If u dont mind , You have to check once again and dont forget set path environment variable, If you didn’t set the path Environment variable then you can get the same error.
      Lets try for me.

      Thanking you………….

      1. I’ve tried all of the above steps…the way they are given…
        and as a result…(I don’t know how)…my whole system went down…I started getting blue screen on start up…finally I had to go to the service center to get it fixed(and got my c: formatted 🙁 ).
        Presently I am too scared to try it again,with the apprehension of losing my data again…
        🙁
        please can anyone tell me what could I have missed or overdid something?

    1. Hello,

      I just followed the steps detailed by MK sir, and able to do. If you need help, let me know. I can debug and fix in your env.

      MK sir,

      Thank you very much. You make things very simple.

  79. I liked this blog but one of the steps to check validity of installation did not work for me(or I might have misread it) in the command mvn -version(it appears to be single hyphen in the middle) it should be mvn –version(double hyphen).It ate up lot of my time

  80. I have installed JDK.

    See below the message :

    C:\Documents and Settings\AMITARTI>java -version
    java version “1.6.0_26”
    Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
    Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)

    My maven location is ‘C:\Program Files\Apache Software Foundation’
    I have done all the settings for maven also
    C:\Documents and Settings\AMITARTI>mvn -version

    ERROR: JAVA_HOME is set to an invalid directory.
    JAVA_HOME = “C:\Program Files\Java\jdk1.6.0_20”
    Please set the JAVA_HOME variable in your environment to match the
    location of your Java installation

    My original java location is ‘ C:\Program Files\Java\jdk1.6.0_20’

    it has two folders :
    jdk1.6.0_20
    jre6

    and jdk1.6.0_20
    has two jre i.e. jre6 and jre

    I do not know, what’s wrong with the configuration.

    Kindly help me out.

  81. Carefull if you make changes to environment variables, you have to close and reopen your windows console if it was first open ! It happened to me and I couldn’t figure why my changes were not taken into account.

  82. Sir
    first time i try to install maven,
    I extract my maven in C:\Program Files\apache-maven-3.0.4
    and in command prompt i wrote C:\Users\test>mvn –version
    but it gave
    ‘mvn’ is not recognized as an internal or external command,
    operable program or batch file.
    please tell me where i m wrong

    1. Make sure you set the MAVEN_HOME pointing to your MAVEN home directory as system variable rather than user variable.

  83. Hi

    cmd prompt says unrecognized mvn command even after doig all steps correctly

    C:\Users\ankit.a.jain>mvn -version
    ‘mvn’ is not recognized as an inter
    operable program or batch file.

    1. Make sure you set the MAVEN_HOME pointing to your MAVEN home directory as system variable rather than user variable.

  84. M_R:

    Hi,
    I am new to Maven.I have JDK 1.6, and try set up Maven (on windows7). I set my environment variables and path couple of times but I get the fallowing error. Can you help me with this error.

    C:\>java -version
    java version “1.6.0_30”
    Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)

    C:\>mvn -v
    Apache Maven 3.0.4 (r1232337; 2012-01-17 02:44:56-0600)
    Maven home: C:\Maven\apache-maven-3.0.4
    Java version: 1.6.0_30, vendor: Sun Microsystems Inc.
    Java home: C:\Program Files\Java\jdk1.6.0_30\jre
    Default locale: en_US, platform encoding: Cp1252
    OS name: “windows 7”, version: “6.1”, arch: “amd64”, family: “windows”
    ‘cmd’ is not recognized as an internal or external command,
    operable program or batch file.
    C:\>

  85. Saved lot of time in understanding web services, Maven, Spring and Hibernate quickly with your step-by-step explanation. Really loved it the way you explained. Thanks a lot.

  86. ————————————————————-
    [ERROR] COMPILATION ERROR :
    [INFO] ————————————————————-
    [ERROR] error: error reading C:\Documents and Settings\ashish\.m2\repository\com\sun\grizzly\grizzly-http\1.9.8\grizzly-http-1.9.8.jar; invalid LOC header (bad signature)
    [INFO] 1 error
    [INFO] ————————————————————-
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 2.593s
    [INFO] Finished at: Wed Apr 25 18:10:56 IST 2012
    [INFO] Final Memory: 8M/15M
    [INFO] ————————————————————————
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (default-testCompile) on project bookstore: Compilation failure
    [ERROR] error: error reading C:\Documents and Settings\ashish\.m2\repository\com\sun\grizzly\grizzly-http\1.9.8\grizzly-http-1.9.8.jar; invalid LOC header (bad signature)
    [ERROR] -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

    plz resolve this by tomorrow

  87. MKyong ,

    I downloaded maven and jdk 1.6 , I have folled all steps for setting Maven in my desktop .After install maven, I have verified in the cmd prompt and version, etc. but i could not figure out version at command line . which is not able to find out. Could you please suggest.

    Thanks in Advance

    1. when you type mvn -version : you could see the version in the first line of response..(as below)

      C:\Users\Ramesh Subburaman>mvn -version
      Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000)
      Maven home: C:\apache-maven-3.0.4\bin\..
      Java version: 1.6.0_13, vendor: Sun Microsystems Inc.
      Java home: C:\Program Files\Java\jdk1.6.0_13\jre
      Default locale: en_GB, platform encoding: Cp1252
      OS name: “windows vista”, version: “6.0”, arch: “x86”, family: “windows”

  88. C:\Documents and Settings\Mukesh>mvn –version
    [INFO] Scanning for projects…
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 0.250s
    [INFO] Finished at: Thu Mar 22 01:08:50 IST 2012
    [INFO] Final Memory: 1M/4M
    [INFO] ————————————————————————
    [ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\Documents and Settings\Mukesh).
    Please verify you invoked Maven from the correct directory. -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException

    i am getting this error

  89. Thanx.
    This is very clear and useful.
    But after installing I get “cmd is not internal or external command”, What can I do for that?

  90. 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”

  91. 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!

    1. Check your Windows “Environment Variable”, classpath variable name in system variable, Windows will find your java command in this classpath.

      1. Hi
        I have already checked it.. It had jdk1.6 itself.. When I installed jdk(version 1.6) earlier, and checked it in cmd, it showed me 1.6 only.

        1. Apache Maven uses the JDK pointed to by the JAVA_HOME variable.

          I recently had to check this for myself and found that even though there were many versions installed and referenced in the classpath, and there was a version in the Windows directory (which was picked up when I used java –version), Maven always sticks with the JAVA_HOME version.

  92. 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.

Leave a Comment

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