mvn command is not recognized as an internal or external command

Right click on My Computer >> Properties >> Advanced system settings >> System Properties window will get displayed Under Advanced >> Environment Variables

Click on New to set Environment Variables

Variable name: JAVA_HOME Variable value: C:\Program Files\Java\jdk1.8.0_121

Variable name: M2 Variable value: %M2_HOME%\bin

Variable name: M2_HOME Variable value: C:\Program Files\Apache Software Foundation\apache-maven-3.5.0

Variable name: Path Variable value: %M2_HOME%\bin

Then click on Ok, ok, ok. Now restart you command prompt and check again with “mvn –version” to verify the mvn is running, you may restart your system also.

It should be working now.


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 \.


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.

Tags:

Maven