Does the -jar
option of the java
command also compile the sources before running the main method?
I believe so but i would like to have a better understanding of the internal process, from the man page you can clearly see a small workflow sequence:
-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 @
But it does not mention that it compiles the sources.
Does the
-jar
option of the java command also compile the sources before running the main method?
No, absolutely not. It just specifies the jar
file in which to find the manifest specifying the main class, and (usually) the class file for that class. It definitely doesn't compile anything.
See more on this question at Stackoverflow