cmd cannot find mvn command

孤街浪徒 提交于 2019-12-20 02:36:33

问题


I just installed Maven and added the \bin directory of maven to my path variables. When I try to use the mvn command in the Command Prompt I just get a message:

mvn: command not found

Everything else I found on here did not help yet.

Edit:

I used https://maven.apache.org/install.html to install maven.

SET PATH=%PATH%;C:\Program Files\Maven\apache-maven-3.5.0\bin\mvn.cmd
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

回答1:


You have included the file in the path:

C:\Program Files\Maven\apache-maven-3.5.0\bin\mvn.cmd

That is not good. The PATH environment variable should only include a path to where files, like exe and cmd's can be found.

Adapt your PATH to read like this:

C:\Program Files\Maven\apache-maven-3.5.0\bin

(so remove the \mvn.cmd). Make sure to start a new command prompt to verify if your path settings are correct.

See How can I set user environmental variables (such as PATH) from a non-administrator account on Windows 7 to find the correct Windows dialog to adapt the settings among many more.




回答2:


Following this tutorial by mkyong, I was able to get this to work on Windows 10 (v10.0.15063):

  1. Install JDK and setup JAVA_HOME system variable

  2. Download Maven zip, extract it and setup M2_HOME and MAVEN_HOME system variables to point to root maven folder (without \bin)

  3. Update PATH system variable to include %M2_HOME%\bin (this is what will let you run "mvn" in Command Prompt).

  4. Open Command Prompt (cmd.exe) and execute mvn -version


You can download Maven (apache-maven-3.5.0-bin.zip) here, if you don't have it already.

The Java SDK (jdk-8u144-windows-x64.exe) can be downloaded from Oracle here.




回答3:


This is my working maven configuration on Windows 10. Was more cumbersome to configure on W10 than on WXP or W7.



来源:https://stackoverflow.com/questions/43830646/cmd-cannot-find-mvn-command

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