我想使用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 位。
最佳答案
jar.exe
是 JDK
的一部分,而不是 JRE
。指向 JDK 7 的路径。
只需转到路径 C:\Program Files\Java\jre7\bin
并搜索 jar.exe
。你永远不会在那里找到它。
第一个注释 java
工作正常,因为 java.exe
存在于 JDK 和 JRE 中。
关于java - 正确使用jar命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25210836/