Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I entered mvn command in windows, but the command line return a java hint

Tags:

java

maven

I have maven 3.3.1 and java 1.7 installed on my machine, windows 8.1.

MAVEN_HOME=C:\Program Files\Apache\apache-maven-3.3.1
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_75
Path=%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;%MAVEN_HOME%\bin;

I've tried to access mvn command line, under C:\Users\{myusername}>, it works well:

C:\Users\{myusername}>java -version
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)

C:\Users\{myusername}>mvn -version
Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-13T13:10:2
7-07:00)
Maven home: C:\Program Files\Apache\apache-maven-3.3.1\bin\..
Java version: 1.7.0_75, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_75\jre
Default locale: en_US, platform encoding: GBK
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "windows"

But when I change the command path to D:, another disk in my machine, the output becomes:

D:\>mvn --version
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32          use a 32-bit data model if available
    -d64          use a 64-bit data model if available
    -server       to select the "server" VM
    -hotspot      is a synonym for the "server" VM  [deprecated]
                  The default VM is server.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A ; separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument

    -splash:<imagepath>
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for m
ore details.

D:\>java -version
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)

Besides, when I use Intellij to create maven project, just like quickstart, the similar error happened:

-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.[ERROR] Maven execution terminated abnormally (exit code 1)

I've tried like mvn -version, mvn -d. But they still do not work. Could anyone please help? Thanks!!

Updated: Now my environment variables is set to:

JAVA_HOME=C:\Program Files\Java\jdk1.7.0_75;
CLASSPATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
M2_HOME=C:\Program Files\Apache\apache-maven-3.3.1;
MAVEN_HOME=C:\Program Files\Apache\apache-maven-3.3.1;
PATH=%JAVA_HOME%\bin;%M2_HOME%\bin;{others...}

And the problem still exists.

Updated:

Whenever I type after mvn command in D: path, the command line will just return java hint; it seems all the things after mvn are ignored. Just like this:

D:\>mvn fewadsfe
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32          use a 32-bit data model if available
    -d64          use a 64-bit data model if available
    -server       to select the "server" VM
    -hotspot      is a synonym for the "server" VM  [deprecated]
                  The default VM is server.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A ; separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument

    -splash:<imagepath>
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for m
ore details.
like image 352
LoGWRiTer Avatar asked Mar 28 '15 02:03

LoGWRiTer


People also ask

Why Maven is not showing in command prompt?

mvn -version 'mvn' is not recognized as an internal or external command, operable program or batch file. Answer: Refer to Step 4, make sure the %MAVEN_HOME%\bin is added to the PATH system variable. Answer: Refer to Step 2, make sure JDK is installed and the JAVA_HOME system variable is configured.

How do you check if Maven is installed on Windows command prompt?

To verify whether maven is installed or not, open the command prompt and write: mvn −version.

Where do I run mvn commands?

To build a Maven project via the command line, you use the mvn command from the command line. The command must be executed in the directory which contains the relevant pom file. You pass the build life cycle, phase or goal as parameter to this command.


2 Answers

I had the same problem in Windows Server 2012 R2 with Apache Maven 3.6.0. It was a strange issue.

I had to delete C:\.mvn Folder and it worked!

With C:.mvn Folder

Without C:.mvn Folder

like image 154
YasithaB Avatar answered Nov 15 '22 20:11

YasithaB


I too have this problem with maven 3.3.1 and windows 7 and I have found this answer in a forum. In this version of maven there is a problem with the command line being issued in the root directory of a drive (c:\, d:\, ...). Issuing the command on any other directory works.

like image 29
etricky Avatar answered Nov 15 '22 18:11

etricky