Reputation: 497
With Eclpise (and other tools), it is possible to include a dependency jar inside another jar (see this answer). When Eclipse do that, it generates a custom class loader, because "classic" class loaders are not able to find a class in a jar that is inside another jar.
To create my jar (package.final.jar
), I :
- Imported the jar to include (dep.jar
) inside a libs/
folder in my project ;
- Added dep.jar
in MANIFEST.MF -> Runtime -> Classpath (so it added the line Bundle-ClassPath: libs/dep.jar,.
to my manifest) ;
- Exported my project as a deployable plug-ins and fragments.
And package.final.jar
contains only this structure :
-META-INF/MANIFEST.MF
-package/-class1.class
-class2.class
.
.
.
-libs/dep.jar
So I am wondering, where is the custom class loader created by Eclipse ?
Upvotes: 0
Views: 217
Reputation: 111142
For Eclipse plug-ins the Bundle-ClassPath
entry in the plug-in's MANIFEST.MF tells the Eclipse / OSGi system which classes and jars in the main plug-in jar are part of the class path.
There is no extra code added to the plug-in jar, the Eclipse class loaders deal with the included jars.
So you can build the jar however you like as long as the MANIFEST.MF is correct. Using maven + Eclipse tycho is common these days.
Upvotes: 1
Reputation: 51
You should have the following folder inside your jar: org/eclipse/jdt/internal/jarinjarloader
Containing the Classloader etc.:
You can also check it if you look into the META-INF/MANIFEST.MF-File to see what Main-Class is set
Upvotes: 0