我想使用java命令,所以我在互联网上搜索了很多。
我发现的是创建一个名为PATH
和值为%PATH%;C:\Program Files\Java\jre7\bin
的新用户变量。
重新启动后,我在cmd:java
中写道,它显示:
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.
然后我输入cmd:jar
并显示:
'jar' is not recognized as an internal or external command,
operable program or batch file.
为什么它识别出第一个命令而不识别第二个命令?
我的操作系统是Windows 8 64位。
答案 0 :(得分:1)
jar.exe
是JDK
而不是JRE
的一部分。指向JDK 7的路径。
只需转到路径C:\Program Files\Java\jre7\bin
并搜索jar.exe
即可。你永远不会在那里找到它。
第一条评论java
运行正常,因为JDK和JRE中都存在java.exe
。
答案 1 :(得分:1)
因为jar
命令随JDK一起提供,而不是与JRE一起提供。安装JDK并将其添加到PATH。