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 ?



mvn -v


mvn --version


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.


mvn -h


mvn --help


-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 PanelUser AccountsUser 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 Pathbut you didn’t open a new command prompt.
    • open a new command prompt, because the environment variables are not updated automatically


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


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

enter image description here

Step 3: Update PATH variable
enter image description here

Step 4: Make sure you have JAVA_HOME variable correctly
enter image description here

step 5: open console and check below command

mvn -v


You need to add path to svn.exe file to system environment, variable PATHafter that you can run command mvn from any folder. You can do it from command line(cmd.exe) like this, for example:

set PATH=%PATH%;C:mavenbin

Or you can got to the folder where mvn.exe is, and run your command there.

And you need not mvn -versionbut mvn --version parameter.


On terminal type mvn -v and the output will look like the image shown below

enter image description here

Open command prompt go inside the maven folder and execute mvn -version, it will show you maven vesrion al

you can use just


i faced with similar issue when i first installed it. It worked when i added user variable name- PATH and variable value- C:Program Filesapache-maven-3.5.3bin

variable value should direct to “bin” folder. finally check with cmd (mvn -v) in a new cmd prompt. Good Luck 🙂

On Windows machine open command line terminal :

> mvn -v
Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: C:UsersajaykOneDriveDocumentsapache-maven-3.8.3
Java version: 11.0.12, vendor: Oracle Corporation, runtime: 
C:Program FilesJavajdk-11.0.12
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: 

3 ways to run Spring Boot apps from command line – Java Brains