[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 413

# Installation of Maven

Hi,

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 :-
SYSTEM VARIABLE
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

In my USER VARIABLES,
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 !

0
sylph
• 2
• 2
1 Solution

Author Commented:
Just to add in, the java is installed correctly. I typed in "java -version" in cmd and returns me the java version. Thanks
0

Commented:
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
0

Author Commented:
Hello,

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

Commented:
sylph,

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
0

## Featured Post

• 2
• 2
Tackle projects and never again get stuck behind a technical roadblock.