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