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/