Reputation: 6378
I want to know how does an executable jar file (which is added as a library) work with the main program.
For example when an executable jar file is added, and if it was not called within the source code of the main program, does it have any effect?
Is an executable jar file the same as a run time library?
Upvotes: 2
Views: 1186
Reputation: 347
Answer is No, It is just standard JAR file which contains a class with Main method init. This main method's location information gets stored in metadata. If you run this jar file then this class & thus main method gets called.
Otherwise it is just normal JAR file. You can add it to any application's classpath & it has same effects as other normal JAR files. Main method still exist but won't get executed.
Upvotes: 1
Reputation: 32949
An "executable jar file" is simply one that has a class that defines a main
method and where the jar file maintains metadata about where to find this main method.
If this jar is not the jar used to launch the JVM, then this metadata is ignored and the jar is treated just like any other jar file (no effect unless explicitly used by something else).
Upvotes: 3