mvn' is not recognized as an internal or external command

旧街凉风 提交于 2019-12-24 07:38:14

问题


I have created these variables with their respective values, but even after doing this, command prompt is not recognizing mvn command
System Variables:

  • name: M2_HOME
  • value: C:\Program Files\apache-maven-3.2.1

  • name: M2
  • value: %M2_HOME%/bin;

  • name: path
  • value: %JAVA_HOME%\bin; %M2_HOME%\bin;

回答1:


From Maven documentation page:

Maven, like many cross-platform tools, can encounter problems when there are space characters in important pathnames. The instructions below will remind you of this for several particular items.

You have Maven installed in C:\Program Files\apache-maven-3.2.1

Try to reinstall it to, for example, C:\maven, or change your current variable M2_HOME to C:\PROGRA~1\apache-maven-3.2.1




回答2:


try :

  • to restart the command prompt
  • to start the command prompt with run/cmd instead of shift+right-click -"open command window here"
  • to put the system path between double quote to manage espace character
  • to replace C:\Program Files\ per C:\PROGRA~1\

edit

this is my own config :

MAVEN_HOME="C:\Program Files\apache-maven-3.2.1"

PATH=XXX;%MAVEN_HOME%\bin;XXX



回答3:


Hello I had the same problem and I figured it out that I was including some space characters on the "path" next to the ; just by removing the space character I was able to have everything working properly"




回答4:


this is the settings for my maven.

name: MVN_HOME value: C:\Program Files\apache-maven-3.2.1

name: path -> add the following value(just the maven part) value: %JAVA_HOME%\bin;%MVN_HOME%\bin; -> this should have no spaces




回答5:


I have a very difficult time to solve this problem. It did not work no matter how I set up the environment variables in the control panel of Win7.

My final solution is to set the variables via the cmd.

set M2_HOME "D:\Program Files\Maven\apache-maven-3.3.3"
set M2=%M2_HOME%\bin
set path=%path%;%M2%



回答6:


I think you have a typo:

change

name: M2
value: %M2_HOME%/bin;

to

name: M2
value: %M2_HOME%\bin;

if it doesn't work change %M2_HOME%\bin with the path. in this case:

C:\Program Files\apache-maven-3.2.1\bin




回答7:


Make sure to set the path under the System Variables and not User Variables.




回答8:


In my case, for reasons I cannot explain, it made a difference to windows 7 if the MAVEN_HOME environment variable was defined in "System Variables" vs "User Variables".

I originally had both JAVA_HOME and MAVEN_HOME as "User Variables" and "Java -version" worked but windows could not find mvn (My path variable looked like this in both cases "Path=C:\Program Files\Java\jre1.8.0_144\bin;E:\Clif\Java\apache-maven-3.6.0\bin;")

Once I changed both Environment variables from "User Variables" to "System Variables" windows was able to find mvn.




回答9:


I had the same issue.

What I did to resolve this is creating M2_HOME & MAVEN_HOME. Also, edit Path variable value.

New ->C:\Program Files\Apache Software Foundation\apache-maven-3.6.0\bin

where Apache Software Foundation is a folder I created to extract the apache-maven-3.6.0-bin.zip file.

Also, make sure Java is working fine and JAVA_HOME is properly set.




回答10:


I was using %MAVEN_HOME% in the variable path and it was giving problem, even though echo %MAVEN_HOME% command was showing the right path.

I changed it to C:\Program Files\apache-maven-3.6.1\bin in the path (Depends on your version of-course) and it worked like a charm.



来源:https://stackoverflow.com/questions/24158156/mvn-is-not-recognized-as-an-internal-or-external-command

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