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?
This question is related to
java
apache
maven
windows-xp
running maven to win 7
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)
Running command prompt as Administrator solved the problem for me. I did not have to move M2 or M2_HOME under system variables.
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.
I have got it solved by adding Path variable in user variables as %JAVA_HOME%\bin;%M2_HOME%\bin;
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
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
Delete M2 and M2_HOME from user variables and move to system variables. That will solve the problem
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.
Looks like maven is not present in your PATH. Add the absolute maven home\bin location to your PATH.
same problem.
and I solved it by:
and then mvn --version
works.
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.
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:
C:\Program Files\apache-maven-3.5.3\bin;
immediately after:
C:\Program Files\Java\jdk\1.8.0_161\bin;
remember to add semi-colon ;
after \bin
as included above and then run your cmd prompt and type:
mvn -v
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.
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.
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.
Heres 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
Just adding some more info that solved the problem for me:
Thanks to Pawan Valecha and Abhijeet Sawant for the tips.
Download apache-maven-3.3.9-bin.zip
file and extract it.
Then set system variable M2_HOME = B:\sql software\apache-maven-3.3.9
or as appropriate
Also set variable M2 = %M2_HOME%\bin
Open CMD
and write mvn
I solved thank you
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 your M2
and/or M2_HOME
accordingly.
It doesn't matter whether M2
or M2_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.
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
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.
Had the same problem,
mvn --version
worked but
maven --version
did not. I prefer using 'mvn' over 'maven' anyway so all is well. I also logout/login in to be sure.
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).
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.
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.
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.
Source: Stackoverflow.com