Installation of Maven

Posted on 2009-12-17
Last Modified: 2013-11-24

I downloaded maven apache from , and followed the installation guide at for Windows XP (I'm using windows 7 actually).

I unzip the downloaded archive, put it in C:\Program Files\Apache Software Foundation
Thus the path will be C:\Program Files\Apache Software Foundation\apache-maven-2.2.1\

I set my environment variable as follow :-
M2_HOME   -> C:\Program Files\Apache Software Foundation\apache-maven-2.2.1\bin
PATH -> %M2_HOME%;  //added this at the end of the line

I have my JDK installed at
PATH -> C:\Program Files\Java\jdk1.6.0_17\bin  //added this at the beginning of the line
JAVA_HOME -> C:\Program Files\Java\jdk1.6.0_17

I have these :
M2 ->  %M2_HOME%

Then I went to cmd line , cd to C:\Program Files\Java\jdk1.6.0_17\bin and type "mvn install" , and enter

I get this error :
M2_HOME is set to invalid directory
M2_HOME = "C:\Program Files\Apache Software Foundation\apache-maven-2.2.1\bin"
Please set the M2_HOME variable in your environment to match the location of Maven installation.

Can anyone point out which part I have done wrong? I tried to change the path to different path, like without the "bin" ,then reboot, but I still get the same error.

Thanks !

Question by:sylph

    Author Comment

    Just to add in, the java is installed correctly. I typed in "java -version" in cmd and returns me the java version. Thanks
    LVL 6

    Accepted Solution

    M2_HOME  should not contain bin
    Wrong: C:\Program Files\Apache Software Foundation\apache-maven-2.2.1\bin
    Correct: C:\Program Files\Apache Software Foundation\apache-maven-2.2.1

    Author Comment


    Thanks for your reply.
    I have changed it, and changed my PATH as well. I "THINK" it's installed but there's build error :
    Cannot execute mojo : resources. It requires a project with existing pom.xml but the build is not using one.

    I wanted to import in some existing projects build on maven to my netbeans too, but after I import in I get various errors. (Should I create a new post for this?). I'm looking at more tutorials too, on how to import existing projects.
    LVL 6

    Expert Comment

    I would recommend to create a new post for other errors as the current issue solved by given solution.
    You should be getting enough information in Netbeans help on how to import existing projects into NetBeans

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now