I am getting the mvn
command not recognized as an internal or external command.
I have setup the M2_HOME, JAVA_HOME and added %M2_HOME%/bin to the path
Restart your machine, after setting up your M2_HOME (pointing to you Maven basedir, NOT the bin
dir) and PATH (PATH=%M2_HOME%\bin;%PATH%
).
Then do:
dir %M2_HOME%\bin\mvn*
If there is a .bat
file, it should work under Windows, as it appears to be finding it. If there isn't one, then your paths are not right and you need to make sure your %PATH%
variable really points to the correct path to Maven.
Make sure you are using the proper slashes for your OS. Under Windows they're \
.
I had this same error but my problem was I had the following:
M2_HOME = C:\Program Files (x86)\Apache Software Foundation\apache-maven-2.2.1;
Which meant my PATH = %M2_HOME%\bin; (etc)
...became C:\Program Files (x86)\Apache Software Foundation\apache-maven-2.2.1;\bin
i.e. a semicolon was where it shouldn't be.
Which I discovered because Michael Ferry suggested using 'ECHO %PATH%' to see what the actual PATH output was.
Try setting the path of maven first through command prompt.
setpath.bat
Open the cmd
from the base window of the batch file.
The rest maven commands can be used once path is set through cmd
.
Windows 10 -
Update variable "path" -
Verify on cmd -
Write the entire maven path into the Environment PATH
variable.
Example:
C:\Program Files\apache-maven-3.2.3\bin;
My PATH
variable wasn't reading %M2%
or %M2_HOME%\bin
properly, and therefore I wrote the full path into the PATH
variable.
Working.
I faced similar problems. The article that helped me solve similar issues is by MKyong and is here: ****https://www.mkyong.com/maven/how-to-install-maven-in-windows/**** It is very important to include in maven's path the file that contains the 'bin','boot', 'conf', 'lib' etc. file folders. For example, in my case, the correct path is: C:\Program Files\Apache Software Foundation\maven\apache-maven-3.5.0-bin\apache-maven-3.5.0