java - 正确使用jar命令

标签 java

我想使用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.exeJDK 的一部分,而不是 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/

相关文章:

java - JOGL:如何快速绘制许多字符串

java - Websphere Application Server 中的 session 共享

java - Tomcat 重新启动时出现错误(退出 143),运行,然后在一段时间后失败

java - 需要在运行时从 WebElement 对象检索 xpath 或 css

java - 将两个数组放在一起

java - 对包含字母数字和字母的 vector 分量进行数字排序

java - apache commons 3.1 中的 httpClient 代理支持

java - DynamoDB 并行扫描 - Java 同步

java - 在java中将列表转换为逗号分隔字符串的最佳方法

java - 不同字符串的 UUID 相同