Please correct me if I am wrong.
When running java [-options] -jar jarfile with no explicit class name, if a single class exists within the jar that contains a public static void main(String[] args) method, that method will be invoked automatically. Right?
What happens if I have several classes that contain an eligible main method?
It uses the Main-Class defined in the MANIFEST file to determine which class contains the main method that should be run.
see http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html
The class to run is taken from the Manifest metadata.
Main-Class :
The value of this attribute defines the relative path of the main application class which the launcher will load at startup time. The value must not have the .class extension appended to the class name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With