Both the types standard and runnable contains the Manifest file and java class files. The difference is in the content of Manifest file.
The Manifest file for runnable jar has an entry for main class:
Main-Class: com.kpmg.rohit.appraisalStrory.StoryTeller
That means runnable jar specifically specifies the entry point of jar.
So if you just want to bundle your project in a library to be used by any application, any type of jar will suffice. But, say, you want to execute by command line, the difference will be clear
So, I have two jars for same project, one exported as runnable and other as standard jar
Let me try to run both of them via command prompt:
The runnable jar is executed but standard jar throws an error, because java does not the entry point to this jar.
We can explicitly specify the class with main method to execute the standard jar as well
That is it, hope you get it.
No comments:
Post a Comment