Can't access mvn command from command line?

陌路散爱 提交于 2019-12-11 02:49:08

问题


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?


回答1:


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.




回答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




回答3:


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



来源:https://stackoverflow.com/questions/20029934/cant-access-mvn-command-from-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!