java – mvn is not recognized as an internal or external command, operable program or batch file

java – mvn is not recognized as an internal or external command, operable program or batch file

My problem solved, path didnt resolve %M2%. When i added location of maven-bin in the path instead of %M2% after that commands works.

I would like to thanks to all those who try to solve the problem

This problem arise because there is no any environmental variable corresponding to installed maven in your OS.
For fixing this problem, I always use Intellijs bundled Maven and do not install separate version of Maven again, for finding bundled Mavens path go to intellij and hit Ctrl+Alt+S -> Build, Execution, Deployment -> Build tool -> Maven -> Maven home directory you can find the intellijs bundled maven path there as below image demonstrates.

enter

Then go to System environment variables and set these variables:

Variable name: MAVEN_HOME

Variable value: C:/Program Files/JetBrains/IntelliJ IDEA 2019.3.1/plugins/maven/lib/maven3

enter

After defining system variable MAVEN_HOME find variable path and add this line to the list

%MAVEN_HOME%bin

enter

Work is done, open command prompt and test it by writing mvn -v. 99 percent of the time it work, if youre among 1 percent, you have to restart your computer.

If you want to use mvn command from intellijs internal terminal you have to restart intellij after setting environment variables, then you shouldnt have any problem running maven command from terminal.

java – mvn is not recognized as an internal or external command, operable program or batch file

maven should be on the systems PATH if you wish to execute it from any place. add %M2_HOME%bin to the PATH

Leave a Reply

Your email address will not be published.