2

I've tried to access mvn from command line.

Installation path

C:\Program Files\Apache Software Foundation\apache-maven-3.1.1

User variables

M2 = %M2_HOME%\bin 
M2_HOME = C:\Program Files\Apache Software Foundation\apache-maven-3.1.1
JAVA_HOME = C:\Archivos de programa\Java\jdk1.7.0_25

System variables

Path = %M2%;%JAVA_HOME%/bin; and others...

I try to se if Maven is well configured through mvn --version as the manual says but this is the result:

C:\>mvn --version
"mvn" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.

C:\Program Files\Apache Software Foundation\apache-maven-3.1.1\bin>mvn --version
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 17:22:22+0200)
Maven home: C:\Program Files\Apache Software Foundation\apache-maven-3.1.1
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: C:\Archivos de programa\Java\jdk1.7.0_25\jre
Default locale: es_ES, platform encoding: Cp1252
OS name: "windows xp", version: "5.1", arch: "x86", family: "windows"

What could it be this? Should I export the variables every time I need them?

Aycan Yaşıt
  • 2,106
  • 4
  • 34
  • 40
Joe
  • 7,749
  • 19
  • 60
  • 110

3 Answers3

6
Path = %M2%;%JAVA_HOME%/bin; and others...

If you change %M2% to %M2_HOME%\bin it'll work.

To be precise: if you execute 'set Path' it must contain the path to the bin directory of Maven.

Robert Scholte
  • 11,889
  • 2
  • 35
  • 44
  • And you have to open a new command prompt after setting these values! – Robert Scholte Nov 17 '13 at 11:34
  • no luck :( C:\>set path Path=%M2_HOME%\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;%JAVA_HOME%\bin PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.bat C:\>mvn --version "mvn" no se reconoce como un comando interno o externo, programa o archivo por lotes ejecutable. – Joe Nov 17 '13 at 11:50
  • 1
    You shouldn't mix user variables and system variables. You can also use the `Path` user variable: `Path` `%M2%;%JAVA_HOME%/bin;` Windows will concat them correctly. – Robert Scholte Nov 17 '13 at 11:54
  • System variables can not access user variables! That was the mistake. – Joe Nov 17 '13 at 18:50
2

In my past I was the same (Windows 7) and I solved it by running the cmd as administrator. Click Start - Accessories - click Command System right click Run as Administrator

Rahul
  • 76,197
  • 13
  • 71
  • 125
0
export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9
export M2=$M2_HOME/bin
export PATH=$M2:$PATH

mvn --version

Note: Set Java path if not available

Prashanth Sams
  • 19,677
  • 20
  • 102
  • 125