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:01

Looks like maven is not present in your PATH. Add the absolute maven home\bin location to your PATH.

查看更多
冷血范
3楼-- · 2019-01-13 21:01

I had similar issue on Windows 7. At first I setup M2, M2_HOME under User variable but when I echoed %PATH% , I did not see maven bin directory listed under PATH. Then I setup M2, M2_HOME under system variable and it worked.

查看更多
一夜七次
4楼-- · 2019-01-13 21:02

Most probably you may have not installed maven correctly. use this to download maven. Download the latest (Binary tar.gz) file.It worked for me.

查看更多
Viruses.
5楼-- · 2019-01-13 21:04

running maven to win 7

  1. unzip apache-maven to directory C:\Program Files\apache-maven-3.2.1
  2. go to [Enviroment Variables] set [path] C:\Program Files\apache-maven-3.2.1\bin;
  3. open cmd and type C:\Program Files\apache-maven-3.2.1> mvn -version
查看更多
beautiful°
6楼-- · 2019-01-13 21:05

You need to set M2 and M2_HOME. I was facing same problem and issue was I had put one extra space in PATH variable after semicolon. Just removed space from path and it worked. (Windows 7 machine)

查看更多
孤傲高冷的网名
7楼-- · 2019-01-13 21:07

I've suffered from this problem and found that, for some reason or other, environment variables were simply not being parsed (executing cd %M2% told me that there was no folder %M2% in the current directory). In the end adding the explicit path to Maven's executable worked for me:

C:\apache-maven-3.1.0\bin

查看更多
登录 后发表回答