java - Windows 8 x64 : Usage: java [-options] class [args. 上的 Maven 3.0.4 错误 ..]

标签 java windows eclipse maven maven-3

这是我在这个论坛上的第一篇文章。我在使用 Maven 3 时遇到问题。操作系统:Windows 8 Professional RTM。

如果我运行任何 maven 命令(无论如何),我总是会得到以下答案:

Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file)

where options include: -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 | -jre-no-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
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
              disable assertions
-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

我使用了谷歌和论坛搜索,但唯一的结果是一个不同的问题:这是一个关于环境变量的问题(其中大多数以额外的斜杠结束路径)。

如果我执行 java -version 我得到:

java version "1.6.0_35" Java(TM) SE Runtime Environment (build 1.6.0_35-b10) Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01, mixed mode)

如果我执行 javac -version 我得到:

javac 1.6.0_35

我使用的 Maven 版本是 3.0.4。这些是我添加的环境变量(我添加了 M2_HOME 和 MAVEN_HOME,因为我不确定哪个是正确的变量):

CATALINA_OPTS=%MAVEN_OPTS%
CLASSPATH=%JAVA_HOME%\src.zip;%JAVA_HOME%\lib\tools.jar;
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_35
M2_HOME=d:\software\apache-maven-3.0.4
MAVEN_HOME=d:\software\apache-maven-3.0.4
MAVEN_OPTS=-Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m
PATH=%JAVA_HOME%\bin;%MAVEN_HOME%\bin;d:\software\eclipse;%M2_HOME%\bin

路径环境变量有更多路径,但我只是将我为最后一年的项目添加的路径粘贴在这里。

预先感谢您的帮助。

最佳答案

您唯一需要设置的环境变量是:

JAVA_HOME=C:\Program Files\Java\jdk1.6.0_35
MAVEN_HOME=D:\software\apache-maven-3.0.4
PATH=%PATH%;%MAVEN_HOME%\bin;%JAVA_HOME%\bin

注意,使用 D: 而不是 d:

关于java - Windows 8 x64 : Usage: java [-options] class [args. 上的 Maven 3.0.4 错误 ..],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13092330/

相关文章:

C 代码在 Eclipse-Kepler 中运行,但在 Codeblocks IDE 中运行失败

windows - 在远程机器上调用后台命令

windows - VisualSVN 服务器存储库备份/恢复

java - 将@RequestParam 用于多部分文件是正确的方法吗?

java - Hibernate拦截器不起作用

c++ - 为什么随机数和MSYS2都一样?

java - Eclipse JFace 的向导

android - Android 设备选择器窗口目标栏中的橙色三角形是什么意思?

java - 使用 Hashmap 比较键和值,并根据相似键将值加在一起

java - Spring Restful API,是否有像路由器一样使用方法来获取其他方法的端点或URL?