java - java 命令的 -jar 选项的真正作用是什么

标签 java jar

java 命令的 -jar 选项是否也会在运行 main 方法之前编译源代码? 我相信是这样,但我想更好地了解内部流程,从手册页中您可以清楚地看到一个小的工作流程序列:

-jar
             Execute a program encapsulated in a JAR file. The first argument is the name of a JAR file instead of a startup class name. In order for this option to work, the manifest of the JAR file must contain a  line  of
             the form Main-Class: classname. Here, classname identifies the class having the public static void main(String[] args) method that serves as your application's starting point. See the Jar tool reference page and
             the Jar trail of the Java Tutorial @

但它没有提到它编译源代码。

最佳答案

Does the -jar option of the java command also compile the sources before running the main method?

不,绝对不是。它只是指定 jar 文件,在该文件中查找指定主类的 list ,以及(通常)该类的类文件。它绝对不会编译任何东西。

关于java - java 命令的 -jar 选项的真正作用是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24033212/

相关文章:

java - 需要在 Windows 中使用 wget 复制文件

Java - 从终端运行 jar 可以,但双击会破坏功能

java - 如何使用 Java Mail API 获取有限数量的消息

java - OpenCV 在 Mac 上无法正常工作

java - 移动java应用程序

java - 类路径在哪里?

java - 如何向用户显示我的 Java Swing 应用程序的版本号?

java - Axis 编码器

java - objectify 中的复杂查询

java - SWT 未启用 shell