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 🙂

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

    Reply
  3. I had to restart my PC after setting up Maven Environment Variables to make it work.

    Reply
  4. 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.

    Reply
  5. 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…………..

    Reply
  6. 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.

    Reply
  7. Thank you so much, such easy explanation for beginners. you saved my day

    Reply
  8. Hi there, just to add to the post, on latest versions is

    mvn –version

    Reply
  9. The JAVA_HOME environment variable is not defined correctly,
    this environment variable is needed to run this program.

    Reply
  10. Thank you, worked totally fine for maven version 3.8.1 – Thank you!

    Reply
  11. 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.

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

    Reply
  13. 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! ♥²

    Reply
  14. 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.

    Reply
  15. Thank you so much! Your articles have been helping me for over 8 years 🙂 Most recent time was today 🙂

    Reply
  16. I am getting could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher

    Reply
  17. I have an error while running mvn -version: Error: -classpath requires class path specification

    Reply
  18. 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.

    Reply
  19. Thank you so much!
    This was the most highlighting explanation about adding things to the PATH I ever consulted!

    Reply
  20. 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

    Reply
    1. Hi,

      I am having same issue, did you got any solution on this?

      Reply
  21. 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!

    Reply
  22. we have to include the bin in the environment like this “*\apache-maven-3.6.3\bin “

    Reply
  23. This could not be any clearer. Thank you very much.

    Reply
  24. Hi all ,
    I need one doubt which version maven is suitable for java 8

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

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

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

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

    Reply
  28. dont follow this guide it is absoolute shitty! go youtube or search for another guide that actually works, thanks!

    Reply
  29. 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

    Reply
  30. 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.

    Reply
  31. Got a problem while installing Maven. Thankfully found your tutorial. 🙂

    Reply
  32. what about “M2_HOME”, you didn’t mention it.

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

    Reply
  34. This came as a blessing. Thank you so much,

    Reply
  35. Very useful. thanks for the mvn tutorial

    Reply
  36. This is really helpful mkyong,kudos!

    Reply
  37. Very, very, VERY helpful. This isn’t very clear on the Maven website. Thank you!

    Reply
  38. This post helped me alot…… Thanks for sharing…..

    Reply
  39. It worked for me, after adding variable we need to restart system also

    Reply
  40. 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

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

    Reply
  42. 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.

    Reply
    1. But the same does not appear on command prompt meaning that It works well when using command prompt.

      Reply
  43. changed maven’s directory from c:\opt\apache-maven-3.6.0 (not working) to C:\Program Files\apache-maven-3.6.0 (fully working)

    Reply
  44. Hi Guys, Its working fine…So u can follow above step to configure Maven.

    Reply
  45. 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

    Reply
  46. Thank you very much. This is better than the original post from Apache

    Reply
  47. Thank you for your efforts. I always forget how to do that 🙂

    Reply
  48. 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.

    Reply
  49. 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)

    Reply
  50. Great yong, thanks much, really appreciated, worked well

    Reply
  51. Ha, this was written almost 10 years ago and it’s still useful! Thanks

    Reply
  52. Crisp clear … Thanks for sharing this.

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

    Reply
  54. 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…

    Reply
    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)

      Reply
    2. I am facing the same problem, can someone please help me out

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

        Reply
  55. 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!

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

    Reply
  57. 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.

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

    Reply
  59. 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.

    Reply
    1. thanks a lot Lisa for the win 10 note and for detailed explanation, it worked very well ..much appreciated

      Reply
  60. 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.

    Reply
  61. 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.

    Reply
  62. 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.

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

    Reply
  64. 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.

    Reply
    1. You are correct. Binary.zip should be downloaded.

      Reply
  65. 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!

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

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

    Reply
    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

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

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

        Reply
        1. you are absolutely right after adding on user var too , it works, Thank you so much

          Reply
      1. Thanks for such a simpler way of making understand

        Reply
      2. 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.

        Reply
      3. I have added the absolute path of \bin folder at the end of PATH variable and issue related to step 4 resolved

        Reply
  68. Perfect, thanks! I love it when something actually works first time!

    Reply
  69. Thanks good tutorial,guided step by step process.

    Reply
  70. 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>

    Reply
  71. thank you so much. most helpful guide on the internet.

    Reply
  72. Thanks good tutorial,guided step by step process.

    Reply
  73. 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!

    Reply
  74. 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.

    Reply
  75. mvn — version
    not mvn -version
    double minuses

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

    “mvn –version”

    Reply
  77. 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

    Reply
  78. Please add the statement: Restart your computer.

    Reply
  79. You’re great dude!!! I wish I could pay you back what you do

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

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

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

        Reply
  81. 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!

    Reply
  82. 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?

    Reply
  83. 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.”

    Reply
  84. i have done all the process below but it is still showing the same error

    Reply
  85. 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>

    Reply
  86. error: M2_HOME is set to an invalid directory.
    how to resolve it??

    Reply
  87. Thanks a lot for this tutorial! Helped me when all other steps and instructions failed…!

    Reply
  88. 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

    Reply
  89. For the path the end should be a semicolon not a comma.
    This: – %M2_HOME%bin;

    Not this: – %M2_HOME%bin,

    Reply
  90. thanks dear with the help of your tutorials i have easily setup mavan on my system

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

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

    Reply
  93. 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.

    Reply
    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

      Reply
  94. 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

    Reply
  95. 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?

    Reply
  96. 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

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

      Reply
        1. I tried with comma and it worked but why comma?

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

      Reply
      1. I just tried the steps mentioned in the above blog (not any comments), restarted cmd and it worked fine.

        Reply
    3. Make sure MAVEN_HOME is configured and %MAVEN_HOME%bin is added to the PATH.

      Refer Step 3 and Step 4.

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

      Reply
      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

        Reply
      1. Thank you bro!!! Damn wasting time just to download this things!!

        Reply
  97. 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

    Reply
  98. help me please i have error :

    org.codehaus.plexus.classworlds.launcher.launcher

    Reply
    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]

      Reply
  99. 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.

    Reply
  100. 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.

    Reply
  101. 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

    Reply
  102. After few hours spending a lot of time configuring maven, you saved my life! Thank youuu

    Reply
  103. 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!

    Reply
    1. So that you can run Maven’s command everywhere 🙂 , ya, sometime they like to use short form.

      Reply
  104. Hey, thank you very much. You always make everything easier. Cheers!!!

    Reply
  105. Hi mkyong , your way of explaning these tutorials good. Super

    Reply
  106. An alternative is to install using chocolatey.org.

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

    Voila!

    Reply
    1. Thanks for sharing this “apt-get” style on Windows!

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

    Reply
  108. Thank you Mykong.. your directions were much better than Apache’s

    Reply
  109. 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 ..

    Reply
  110. 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

    Reply
  111. 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.

    Reply
      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”

        Reply
    1. Hi Surfer,thanks a lot i had the same issue.

      Reply
  112. 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..

    Reply
  113. 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 ..

    Reply
    1. You should set JAVA_HOME variable is “C:/Program Files/Java/jdk1.7.0_10” and Path is %JAVA_HOME%\bin.

      Reply
  114. 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

    Reply
    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

      Reply
  115. When I wrote mvn -version it display an error (Build Failure error)

    but it the worked when I typed:
    mvn –version

    Reply
  116. Thanks Mkyong, you make everything simple and easy. Salute

    Reply
  117. 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

    Reply
    1. Sorry, I try my best to answer, but too many comments, and often times, I’ve missed some…

      Reply
    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…”

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

    Reply
  119. Thank you very much.
    Crystal clear step by step explanation as always.

    Reply
  120. 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!

    Reply
      1. You need to run the mvn command from the folder that contains the batch file.
        e.g. c:\maven\bin

        Reply
  121. Hi

    Thank you for your post it was really helpful

    Regards
    Rajesh

    Reply
  122. 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.

    Reply
    1. There is no question here. You need to tell us what the actual problem is.

      Reply
      1. Though you could try running the mvn command from the folder that contains the batch file.
        e.g. c:\maven\bin

        Reply
  123. 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

    Reply
  124. 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.

    Reply
    1. Nitesh, you need to restart your PC in order for the environment variables’ changes to take effect.

      Reply
      1. No you don’t.
        You need to run the mvn command from the folder that contains the batch file.
        e.g. c:\maven\bin

        Reply
    2. can you please give details related to environment variable how you have configure ?
      i think the issue is that

      Reply
  125. 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.

    Reply
  126. Very useful & helping me
    Thanks Mkyong u’re rock man!

    Reply
  127. Thanks a ton.. Now I am able to set Maven in my system.. 🙂

    Reply
  128. Very good article thanks a lot for your help Sir.

    Reply
  129. Awesome walkthrough! Thanks alot

    Reply
  130. Thank you so much for the post. It was very helpful and saved my time 🙂

    Reply
  131. Simple and efective, how every “how to” should be! Nice job!

    Reply
  132. Very nice walkthough. Simple and effective.

    Thank you sir!

    Reply
  133. Thanks a lot!! It really helps a lot for biginners.
    Thanks once again!!

    Reply
  134. 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!

    Reply
  135. Thanks! This tutorial help me to solve my problem. 🙂

    Reply
  136. man………thanks a lot. really simple and neatly said. its workin for me……….thank u. 🙂

    Reply
  137. 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!

    Reply
  138. I installed maven in my windows7 in cmd mode mvn -version it is displaying the os version windows vista

    Reply
  139. 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 )

    Reply
  140. Thanks a lot Yong
    It’s very useful to me to learn new technologies .

    Reply
  141. 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

    Reply
  142. 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…

    Reply
    1. anshul..make sure you close everything after completing the steps above and reopen the cmd
      it worked for me.

      Reply
    2. 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………….

      Reply
      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?

        Reply
          1. Finaly I did it…
            Thnx every1 fr ur responses…

            nd Mkyong Sir…thnx a ton…
            🙂

  143. Sir,
    I tried all the steps…
    even from various tutorials.
    Urs is the last 1.
    stil m nt able to get maven done.
    plz help…

    Reply
    1. You just follow exactly what the yong given, definitely you can get success to build maven in your pc

      Reply
    2. 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.

      Reply
      1. Finaly I got maven…
        🙂
        Thnx evry1 fr ur responses…
        🙂

        Reply
  144. 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

    Reply
  145. 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.

    Reply
  146. 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.

    Reply
  147. Above steps worked for me. Thanks !!!!
    Info on this site is really helpful.

    Reply
  148. 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

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

      Reply
  149. when i run mkyong>mvn -version
    it says …access is denied.

    Reply
  150. 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.

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

      Reply
  151. 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:\>

    Reply
  152. 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.

    Reply
  153. Thanks a lot it is very clear and helped me a lot.

    Reply
  154. ————————————————————-
    [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

    Reply
  155. 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

    Reply
    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”

      Reply
  156. Excellent, very helpful thank you for your efforts!

    Reply
  157. 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

    Reply
    1.  it is --version (double hyphens) not single one 
      Reply
  158. 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?

    Reply
  159. 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

    Reply
  160. 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”

    Reply
  161. 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!

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

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

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

          Reply
  162. Hi

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

    Reply
  163. 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.

    Reply
    1. Article updated for prerequisite requirement. It look like you have no JDK install or doesn’t configure the JAVA_HOME environment variable in Windows.

      Reply

Leave a Comment

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