Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvn command is not recognized as an internal or external command

Tags:

maven

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 variable. All are system variables. Still getting the same problem.

Echoing the variables showing me the correct paths.

Path to Maven: C:\apache-maven-3.1.0\apache-maven-3.1.0

M2_HOME:C:\apache-maven-3.1.0\apache-maven-3.1.0

PATH: Other things,C:\Program Files (x86)\Java\jdk1.7.0_40\bin,C:\apache-maven-3.1.0\apache-maven-3.1.0\bin

and I have restarted my computer twice.

like image 294
saurav Avatar asked Sep 30 '13 09:09

saurav


People also ask

Why mvn is not recognized?

mvn -version 'mvn' is not recognized as an internal or external command, operable program or batch file. Answer: Refer to Step 4, make sure the %MAVEN_HOME%\bin is added to the PATH system variable. Answer: Refer to Step 2, make sure JDK is installed and the JAVA_HOME system variable is configured.

How do I know if Maven is installed on Windows?

Once Maven is installed, you can check the version by running mvn -v from the command-line. If Maven has been installed, you should see something resembling the following output. If you see this output, you know that Maven is available and ready to be used.


2 Answers

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.

like image 187
Sandeep Nehte Avatar answered Sep 21 '22 10:09

Sandeep Nehte


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

like image 25
carlspring Avatar answered Sep 23 '22 10:09

carlspring