Reputation: 4054
I was creating a runnable jar using eclipse indigo where I encountered two options:
Extract required libraries into generated jar
and
Package required libraries into generated jar
While the creation using first option generated only a jar file with the application packages and the META-INF
package, the second option also created an org
package.
This org
package was further extended by its sub-folders as org> eclipse> jdt> internal> jarinjarloader
. The jarinjarloader
package contained a few classes I haven't seen before.
This is my manifest file in second option:
Manifest-Version: 1.0
Rsrc-Class-Path: ./
Class-Path: .
Rsrc-Main-Class: main.SimpleCalculator
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
main
is my application package and SimpleCalculator
is my main class.
My questions are:
1) How do these two options differ and what are these new classes added by the second option? Also what are the different name-value pairs in the manifest of second option?
2) Also, is there any difference between a non-runnable and runnable jar except for their manifest files allowing the runnable to become executable. (I found option to specify the main-class in my project while creating even a non-runnable jar file, so am I missing something here or is it just eclipse trying to be extra helpful?)
Note: I have some guesses about these two options but they are just that... guesses!
Thanx in advance!
Upvotes: 1
Views: 1156
Reputation: 1037
Answer to first question is that the first option extracts the dependency class files and resources and then packages them as into your jar file, you need to pay attention to license issues using this option
As for the second option, it only packages i.e.: adds the jar files as is to your jar files, and referencing them through the MANIFEST.
There's also one more option for creating runnable jar files, which places all your dependency jar files in a folder adjacent to your project's runnable jar, and including references to the jar in that folder within the MANIFEST.
The answer to your second question is, yes eclipse is trying to make life a bit easier by using your Runtime Configurations so that you can create a runnable jar based on any configuration you select. You could create a runnable jar by manually creating your MANIFEST including the main class in it.
Upvotes: 2
Reputation: 9579
1) How do these two options differ?
What is the difference between runnable jar library handling options?
2) what are these new classes added by the second option?
org
package is for jar-in-jar-loader. With package option
it would become fat jar and your main class would not be the real main any more, see manifest in that case.
From Ant, but you get the idea right?
<attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"/>
<attribute name="Rsrc-Main-Class" value="YourRealMainClass"/>
3) Also, is there any difference between a non-runnable and runnable jar except for their manifest files?
I don't think so, however exporting non-runnable jar from Eclipse you can specify files to include and not more flexibly.
Upvotes: 2