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 ?
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).
You need to add path to svn.exe file to system environment, variable PATH, after 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:\maven\bin
Or you can got to the folder where mvn.exe is, and run your command there.
And you need not mvn -version
, but mvn --version
parameter.
you can use just
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version></version>
</dependency>
Open command prompt go inside the maven folder and execute mvn -version, it will show you maven vesrion al
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:
Path
ECHO.%PATH:;= & ECHO.%
in cmd to see if you are in this situation).
M2_HOME=<your_path>
MAVEN_HOME=%M2_HOME%
MAVEN_BIN=%M2_HOME%\bin
;%MAVEN_BIN%
at the end of the Path
Path
, but you didn't open a new command prompt.
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
i faced with similar issue when i first installed it. It worked when i added user variable name- PATH and variable value- C:\Program Files\apache-maven-3.5.3\bin
variable value should direct to "bin" folder. finally check with cmd (mvn -v) in a new cmd prompt. Good Luck :)
Source: Stackoverflow.com