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?
I was facing the same issue while executing the command mvn -version; however, I checked I had also set the mvn options in the environment variables setting, which gave me some Heap memory issue on the command prompt. So, I removed the maven options that I had set and then it worked fine for me.
Had the same problem,
worked but
did not. I prefer using 'mvn' over 'maven' anyway so all is well. I also logout/login in to be sure.
Make sure that you haven't renamed some folder which falls in the path of the
M2
environment variable. In case you have, then change yourM2
and/orM2_HOME
accordingly.It doesn't matter whether
M2
orM2_HOME
are System Variable or User Variables as long as you are logged in with the same user under whose scope the environment variables are.Just adding some more info that solved the problem for me:
Thanks to Pawan Valecha and Abhijeet Sawant for the tips.
Maven should be configured in the following way (can be user variables or system): - M2: %M2_HOME%\bin - M2_HOME: (your directory to Maven's root, not \bin) - PATH: %PATH%;%M2%
You should then be able to run
mvn
from the command prompt.I had the same issue, there was no issue in my syntax, but when I moved the
M2
,M2_HOME
,JAVA_HOME
environment variables from user to system it started working. Path variables stayed the same.