Apache Maven install “'mvn' not recognized

2019-01-13 20:43发布

I've followed the official installation instructions here for Windows XP. But sometimes when I execute mvn --version, I receive the error message,

'mvn' not recognized as an internal or external command

I've even rebooted my machine a couple times, but the OS does not always recognize the maven command. But when I execute either, cd %M2_HOME%, or cd %M2% it brings me to the installation directory. I've also made sure to add the user variable M2 to the Path system variable.

So, what gives?

28条回答
我命由我不由天
2楼-- · 2019-01-13 21:22

Running command prompt as Administrator solved the problem for me. I did not have to move M2 or M2_HOME under system variables.

查看更多
我命由我不由天
3楼-- · 2019-01-13 21:24

I solved this by creating all under user variables (including the PATH variable). This is because the system variables do not "translate" the user variables. So if you only want to use maven in your account, you need to add another PATH variable as a user variable, not system variable.

查看更多
Rolldiameter
4楼-- · 2019-01-13 21:27

As others have done, creating new System variables M2 and M2_HOME solved the problem. Just making User variables M2 and M2_HOME on my Windows XP machine led to maven not being recognised from the command line. I then deleted the User variables, created copies as System variables and it all came to life.

This was apache-maven-3.0.4 with XP sp3. So the instructions in: http://maven.apache.org/download.cgi seem incorrect.

查看更多
Evening l夕情丶
5楼-- · 2019-01-13 21:28

same problem.

and I solved it by:

  1. add C:\Program Files\apache-maven-3.3.9\bin; to PATH
  2. run cmd as administrator

and then mvn --version works.

查看更多
登录 后发表回答