Reputation: 253
using windows 10 system.
downloaded maven
In Environment variables --- I can't add to system variables no access.
In user variables set the M2_HOME
, MAVEN_HOME
both
To path added %M2_HOME%;%M2_HOME%\bin;%MAVEN_HOME%;%MAVEN_HOME%\bin;
Opened command prompt. it's at c:\WINDOWS\SYSTEM32> when i typed mvn -version ---- it says not recognized command
maven is set in user variables in environment settings. what am I missing here? am I checking it right?
Upvotes: 1
Views: 7785
Reputation: 101
I removed all variables from my PC for debugging and tried as shown below - Maven version seem to work fine after setting M2 & MAVEN_HOME. You can follow the same as shown by manually setting the variables in command prompt until you can fix the automatic settings on your PC.
**C:\Users\000>mvn -version
'mvn' is not recognized as an internal or external command,
operable program or batch file.**
C:\Users\000>set MAVEN_HOME=C:\apache-maven-3.6.3
C:\Users\000>set M2_HOME=C:\apache-maven-3.6.3
C:\Users\000>
C:\Users\000>set PATH=C:\apache-maven-3.6.3\bin;%PATH%
C:\Users\000>mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\apache-maven-3.6.3\bin\..
Java version: 11.0.3, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-11.0.3
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
C:\Users\000>java -version
java version "11.0.3" 2019-04-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.3+12-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.3+12-LTS, mixed mode)
Upvotes: 1
Reputation: 101
You may need to try reinstalling the maven setup - It could be corrupted. Try this - Go to maven bin folder and try to print the version . Notice that I havent setup M2_HOME or MAVEN_HOME
See below:
C:\apache-maven-3.6.3\bin>mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\apache-maven-3.6.3\bin\..
Java version: 11.0.3, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-11.0.3
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
C:\apache-maven-3.6.3\bin>java -version
java version "11.0.3" 2019-04-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.3+12-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.3+12-LTS, mixed mode)
C:\apache-maven-3.6.3\bin>set M2_HOME
Environment variable M2_HOME not defined
C:\apache-maven-3.6.3\bin>set MAVEN_HOME
Environment variable MAVEN_HOME not defined
C:\apache-maven-3.6.3\bin>set JAVA_HOME
JAVA_HOME=C:\Program Files\Java\jdk-11.0.3
Upvotes: 1
Reputation: 1731
I am assuming you have JDK installed because Maven needs JDK as a requirement and JAVA_HOME set up as follows,
C:\Program Files\Java\jdk-11.0.3
and path variable contains %JAVA_HOME%
C:\Program Files\Java\jdk-11.0.3\bin
You need to have the M2_HOME setup to the maven installed location. Usually, it is as follows.
C:\Program Files\Apache Software Foundation\apache-maven-3.3.3
And then, you need to have the M2 Variable setup to point to the bin directory like follows,
C:\Program Files\Apache Software Foundation\apache-maven-3.3.3\bin
Path variable should include the %M2%
C:\Program Files\Apache Software Foundation\apache-maven-3.3.3\bin
Then, open up a new command prompt by running CMD in start menu. Then type for
mvn -version
Upvotes: 1
Reputation: 101
Yo can try these :
In command prompt - Run --> set MAVEN_HOME to see if the user variables are setup
Try restarting command prompt and give it a try
run --> set path to see if the values are setup
Upvotes: 2