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

The accepted answer didn't help but simple step below fix it !

Under system PATH: instead of using M2%, use %M2_HOME%\bin, as simple as that.

N.B my %M2_HOME% is pointing to %MV3_HOME% instead of actual absolute path bcos I have multiple version of maven installed and trying to be clever (switch between maven versions on the same box for different project).

查看更多
ら.Afraid
3楼-- · 2019-01-13 21:09

Add your Maven bin path to the System variable as given below

Go to the

> Enviornment Variables > set Path=D:\apache-maven-3.2.1\bin

or if path is already set than append the path with ";"

restart command and try

查看更多
戒情不戒烟
4楼-- · 2019-01-13 21:09

I was facing the same issue and then I closed and reopened cmd.exe to get mvn -vto propagate to my command prompt.

If cmd was open when you set the variables they will not be available in that session.

查看更多
Summer. ? 凉城
5楼-- · 2019-01-13 21:10

Delete M2 and M2_HOME from user variables and move to system variables. That will solve the problem

查看更多
兄弟一词,经得起流年.
6楼-- · 2019-01-13 21:13
  1. Download apache-maven-3.3.9-bin.zip file and extract it.

  2. Then set system variable M2_HOME = B:\sql software\apache-maven-3.3.9 or as appropriate

  3. Also set variable M2 = %M2_HOME%\bin

  4. Open CMD and write mvn

I solved thank you

查看更多
等我变得足够好
7楼-- · 2019-01-13 21:14

I have got it solved by adding Path variable in user variables as %JAVA_HOME%\bin;%M2_HOME%\bin;

查看更多
登录 后发表回答