mvn command is not recognized as an internal or external command

前端 未结 22 2300
执念已碎
执念已碎 2020-12-30 19:20

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

相关标签:
22条回答
  • 2020-12-30 19:44

    In your Environement variable :

    new system variable:

    M2_HOME Your mvn directroy "C:\......\bin"

    new user variable:

    M2 %M2_HOME%

    edit the CLASSPATH by adding %M2%

    finally open the cmd and write

    path=%CLASSPATH%

    enjoy

    0 讨论(0)
  • 2020-12-30 19:46

    Are you trying to reference a user variable in system variables? Try echo %path% and the M2 should have been fully expanded to show the file path to your Maven directory. If it hasn't, then that's the problem.

    To fix it, you should create a user variable called PATH and add your %M2% reference into there.

    0 讨论(0)
  • 2020-12-30 19:48

    I'm using Maven 3+ version. In my case everything was fine. But while adding the M2_HOME along with bin directory, I missed the '\' at the end. Previously it was like: %M2_HOME%\bin , which was throwing the mvn not recognizable error. After adding "\" at the end, mvn started working fine. I guess "\" acts as pointer to next folder. "%M2_HOME%\bin\" Should work, if you missed it.

    0 讨论(0)
  • 2020-12-30 19:48

    I had the same problem. But just restarting my computer after setting up the Maven path resolved the issue.

    Variable Name: M2_Home Variable Value:C:\Apache\apache-maven-3.3.9

    Variable Name: Path Variable Value:C:\ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%JAVA_HOME%\bin\;%M2_HOME%\bin\

    0 讨论(0)
  • 2020-12-30 19:49

    Open Command prompt As "Run As a administrator" and try.

    0 讨论(0)
  • 2020-12-30 19:50

    I faced this problem which kept me busy and buggy for quiet sometime. I was facing the problem (mvn not recognized) after setting up all required environment variables absolutely correctly. So by going by one of the response here, I switched to another version of maven and that fixed the problem.

    Not being completely convinced why it worked this way, I then unzipped the problematic-version and updated env-vars which made it work.

    The problem was when I initially extracted file from the zip, I modified the directory structure a bit. When you extract the zip, say apache-maven-X.x.x-bin.zip, it creates the folder structure as - "apache-maven-3.5.0-bin\apache-maven-3.5.0..."

    In my first attempt I had modified this structure by deleting apache-maven-3.5.0-bin folder and bringing apache-maven-3.5.0 structure one folder up. This was causing the problem.

    0 讨论(0)
提交回复
热议问题