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?
Assuming you've created the variable path for maven as follows:
Under System path, click
new
then edit as follows:Variable name:
MAVEN_HOME
Variable value:
C:\Program Files\apache-maven-3.5.3\bin
Then continue with these instructions:
Under System Path, update variable path by clicking on edit and add:
immediately after:
remember to add semi-colon
;
after\bin
as included above and then run your cmd prompt and type:I had this same problem, restart the command prompt and then check try mvn --version. It was probably set and working the whole time but command prompt needed to be restarted to be able to access the new system variable.
Installtion Steps
C:\Users\XXXXXXX>mvn --version Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T22:11:4 7+05:30) Maven home: C:\apache-maven-3.3.9 Java version: 1.8.0_40, vendor: Oracle Corporation Java home: C:\Program Files\Java\jdk1.8.0_40\jre Default locale: en_US, platform encoding: Cp1252 OS name: "windows 8", version: "6.2", arch: "amd64", family: "dos"
**Make sure all variables have correct values using echo %M2_HOME% on CMD
Way around would be moving
M2
from user variables to system variablesHeres what i did wrong:
1) make sure its NOT in a [C:\Program Files (x86)] it should be in [C:\Program Files] i am not 100% if that could break it but you never know.
2) There were 3 things i needed to do in my Environment Variables to get it to work
A temporary work around would be to set the path from the terminal itself. Worked for me after that. Running as administrator also works. Both M2 and M2_HOME are already set as system variables in my case.