3

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.

BSMP
  • 4,596
  • 8
  • 33
  • 44
Boris
  • 4,944
  • 7
  • 36
  • 69
  • Please verify inside D:\Maven\bin there is mvn.bat exist or not. – Bhuwan Prasad Upadhyay Nov 08 '15 at 00:04
  • Make sure you have your maven bin directory in the path and the JAVA_HOME property set – Bhuwan Prasad Upadhyay Nov 08 '15 at 00:05
  • This is a Windows path issue, not a Maven issue. What does echo %PATH% return? – kervin Nov 08 '15 at 00:33
  • You can consider [this related Q/A](https://stackoverflow.com/q/17432809/4575793). Be aware that (at least for recent Windows) there is a difference between user (above) and system environment variables such as `path`. [Screenshot here](https://i.stack.imgur.com/zHtTQ.png) – Cadoiz Sep 13 '21 at 13:14

3 Answers3

8

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

Bhuwan Prasad Upadhyay
  • 2,916
  • 1
  • 29
  • 33
0

Try to put full maven path upto bin like "C:\Users\ABC\Downloads\maven-2.0.5-bin\maven-2.0.5\bin" directly into path variable of os, then you will be able to understand where problem exists.

Rahul Jain
  • 276
  • 2
  • 11
0

One mistake I did was, There will two environment variables section

One can be accessed via admin while the other one doesn't require any. Please specify the paths in the second place

It will work for sure., also try echo %M2_HOME% to check whether you have configured correctly..before jumping to mvn install

Hope this helps for someone who has to use admin rights