Checking Maven Version
Solution 1:
Shorter
mvn -v
or
mvn --version
Output:
Apache Maven 3.0.5 (...) Maven home: ... Java version: 1.8.0_60, vendor: Oracle Corporation Java home: ... Default locale: en_US, platform encoding: Cp1252 OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"
The other command (mvn -version
) works because it starts with mvn -v
.
You can also try mvn -v123
and you'll get the same output.
Details:
mvn -h
or
mvn --help
Output:
... -V,--show-version Display version information WITHOUT stopping build -v,--version Display version information
Command is not recognized
Probably you are in one of the following 2 situations:
- You didn't add the Maven to the
Path
(runECHO.%PATH:;= & ECHO.%
in cmd to see if you are in this situation).- go to Control Panel\User Accounts\User Accounts
(or click on your photo from the start menu) - click Change my environment variables
- click on New... and add:
M2_HOME=<your_path>
MAVEN_HOME=%M2_HOME%
MAVEN_BIN=%M2_HOME%\bin
- click on Edit... and add the
;%MAVEN_BIN%
at the end of thePath
- go to Control Panel\User Accounts\User Accounts
- You added it to the
Path
, but you didn't open a new command prompt.- open a new command prompt, because the environment variables are not updated automatically
Solution 2:
Type the command mvn -version
directly in your maven directory, you probably haven't added it to your PATH. Here are explained details of how to add maven to your PATH variable (I guess you use Windows because you are talking about CMD).
Solution 3:
Step 1: Start button -> Computer menu item -> Properties on right click menu item -> Advanced System Settings button on left panel -> Advanced tab in System Properties dialog -> Environment Variables button -> System variables table
Step 2: Add MAVEN_HOME variable
Step 3: Update PATH variable
Step 4: Make sure you have JAVA_HOME variable correctly
step 5: open console and check below command
mvn -v