Java – ‘mvn’ is not recognized as an internal or external command, operable program or batch file error in Windows 10

javamaven

I have read similar questions about this problem but it is not working anyways.

I've extracted maven 3.3.3 to D:\Maven (Java already installed and works fine) then added 2 system variables:

Variable Value
M2 %M2_HOME%\bin
M2_HOME D:\Maven

I've also appended next in the path:

%M2%

But it is still not working.

I can execute mvn -version from the D:\Maven\bin but can't do this from another directory.

Best Answer

Don't put extra space in your path after D:\Maven\bin; in D:\Maven\bin; D:\Program Files\NodeJS; Please don't make any space in path variable.

Normally, To set mvn in command line in windows :

  1. Set JAVA_HOME property in system environment
    eg. JAVA_HOME=C:\Program Files\Java\jdk1.8.0_65
  2. Set M2_HOME property in system environment
    eg. M2_HOME=D:\apache-maven-3.3.3
  3. Finally add maven to PATH

    ;%M2_HOME%\bin; add this at the end of PATH property of system environment

Now Try mvn -version

Related Topic