score:103

Accepted answer

the runnable jar contains a manifest.mf file, which defines the main class to be executed when the jar is run.

non-runnable jars are just libraries of classes, that can be added to the classpath so that code is reused (it also contains the manifest file, but no main class there)

score:0

in my case, i used to export as a jar when i had all main class and all the libraries path directory specified in the manifest.mf . if many applications are using same library it is unnecessary to export shared library for each jar. it makes running jar faster. but, many times due to configuration issue in different server class-path cannot access library and in that case it makes sense to export the runnable jar that makes file slow to execute and large.

score:20

with the standard jar file, you have to specify the class with the main method on the command line when running the jar. with a runnable jar, there is a manifest file that will hold that information so you can just type java -jar myrunnable.jar, or simply double click it.

score:20

a runnable jar is a jar file that has an embedded manifest file that includes the "main-class:" declaration. the "main-class" must be defined so the java runtime knows which class to call when the jar is "run." if a jar does not include a manifest with the "main-class:" it is not considered a "runnable jar" - it is just a library of java code.

i would guess this is the difference in how eclipse exports the jar, but not 100% sure.

see this link for more info: http://www.skylit.com/javamethods/faqs/createjar.html


Related Query

More Query from same tag