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
I also was facing with the same issue still after adding path in environment variable and running it as a normal user in command prompt.
Then I opened command prompt and tried running as "Run as Administrator" and I was able to download all the packages with respect to the project.
This is worked for me:
1-download apache-maven-3.3.9-bin.tar.gz file from https://maven.apache.org/download.cgi
2-copy the folder under c:\programfiles
3-set variables as this: M2_HOME ----- C:\Program Files\apache-maven-3.3.9 M2 ----- C:\Program Files\apache-maven-3.3.9
add Path variable to this: ;C:\Program Files\apache-maven-3.3.9\bin
then run the cmd as system admin
it worked.
Try %M2_HOME%\bin
(\
rather than /
)
I have a stupid comment but someone else will have that issue. I was getting that same error when I was trying to put in ./mvnw clean package
and I found out that I had to change it a bit to .\mvnw clean package
and I lived happily ever after.
For me it was not working since I was editing Path variable in "User variable" and adding it under "System variable" made it work. Hope it helps.
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's Working...... Enjoy :)
Thanks Sandeep Nehte