Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
716 views
in Technique[技术] by (71.8m points)

installation - Installing Maven

I am having trouble getting Maven 3.0.3 to install properly. I have read over Unable to install Maven on Windows: "JAVA_HOME is set to an invalid directory" but none of the answers were able to solve my problem.

This is what I did:

  • Went to http://maven.apache.org/download.html and downloaded apache-maven-3.0.3-bin.zip
  • Extracted files to C:Program Files, so I now have a directory called apache-maven-3.0.3
  • Went to my system's environment variables and created user variable M2_HOME, value is C:Program Filesapache-maven-3.0.3in
  • JAVA_HOME variable is set properly, can get version from cmd line
  • Edited PATH so the value is now %SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem;%SYSTEMROOT%System32WindowsPowerShellv1.0;C:Program FilesTortoiseHg;%JAVA_HOME%;%M2_HOME%

When I go to cmd, I this is what I get:

   D:>java -version
    java version "1.6.0_25"
    Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
    Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)

    D:>mvn --version
    'mvn' is not recognized as an internal or external command,
    operable program or batch file.

However, if I am actually in the directory I can do the following:

D:>cd C:Program Filesapache-maven-3.0.3in

D:>C:

C:Program Filesapache-maven-3.0.3in>mvn --version
Apache Maven 3.0.3 (r1075438; 2011-02-28 11:31:09-0600)
Maven home: C:Program Filesapache-maven-3.0.3
Java version: 1.6.0_25, vendor: Sun Microsystems Inc.
Java home: C:Program FilesJavajdk1.6.0_25jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

Is this how it should actually work? From what I have been told I should not have to be in the directory like that to use any mvn commands. Thank you for your time!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just keep these two things in mind :

  • Any filesystem path containing whitespaces in between should be surrounded with double quotes. e.g. set M2_HOME="C:Program Filesapache-maven-3.0.3"
  • PATH should contain the directory in which your executable exists. If M2_HOME is your C:Program Filesapache-maven-3.0.3, the PATH should be %M2_HOME%in

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...