Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking Maven Version

I have just installed maven. I downloaded distributive, extracted files and set bin value environment variables, but when I type mvn -version in CMD I am getting message:

'mvn' is not recognized as an internal or external command,
operable program or batch file.

I am writing project. I have one project DatabaseAPI where I have logic of database and POJO classes. second project is CoreAPI where I have some methods. For DatabaseAPI I make a jar file using eclipse (export -> jar). In core I add external jar (DatabaseAPI.jar). For CoreAPI I make a jar file using eclipse (export -> jar). In core I add external jar (CoreAPI.jar) and I tried to start tomcat (I have servlets in my project and swing too). I got error during starting and error is ClassNotFoundException (One of the classes in CoreAPI did not find). Is it problem of exporting using Eclipse ?

like image 473
Chala Avatar asked Jun 14 '14 15:06

Chala


People also ask

What does the mvn -- version command do?

This command consists of the mvn command which executes Maven, and the build life cycle named clean . This maven command executes the clean build life cycle and the install build phase in the default build life cycle.

Where is Maven installed?

There is no default installation location for maven. It is distributed as a zip file. If you're sure you have maven on your machine, you need to search where you extracted it. You should search for "mvn.

What version of Maven Do I have eclipse?

To check maven plugin version in eclipse: Click Window –> Preferences –> Maven –> Installation . It will show you installation window with Maven version.

What Java version is Maven using?

Before moving on, we can check the default JDK version of Maven. Running the mvn -v command will show the Java version in which Maven runs.


2 Answers

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:

  1. You didn't add the Maven to the Path
    (run ECHO.%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 the Path
  2. 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
like image 72
ROMANIA_engineer Avatar answered Sep 28 '22 03:09

ROMANIA_engineer


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).

like image 22
TheMP Avatar answered Sep 28 '22 02:09

TheMP