can someone tell me please what are the difference between Rsrc-class-Path and Class-Path sections of a runnable-jar's mannifest file?
Now I take them as granted as generated by Eclipse, but I'd like to understand how it works.
What I think based on how Eclipse generates code seems that the first is about jars my app needs, the second is always .. But I have no clues what folder . refers to.
The
Class-Pathattribute. This is a standard attribute defined by the JAR file specification. It contains a list of relative URLs for that will be included on the runtime classpath when you run the JAR usingjava -jar ....This provides a way to add external JARs (and directories) to the runtime classpath. The entries must be relative, and are resolved relative to the directory containing the main JAR. (For security reasons ...)
The
Rsrc-class-Pathattribute is non-standard. This is used by Eclipse's "jars-in-jar" launcher. A typical manifest looks like this:where
com.abc.Masteris your apps (real) main class, andlib/xyz.jaris a relative URL for a JAR file that is nested within this JAR.. You will also see that the JAR contains the ".class" file forJarRsrcLoader. This is what happens with you runjava -jar this.JAR arg1 arg2.JarRsrcLoaderclass given byMain-Class/mainmethod, passing it["arg1", "arg2"]JarRsrcLoaderexamines the manifest, and extracts theRsrc-Class-PathandRsrc-Main-Class.JarRsrcLoadercreates a special classloader that knows how read JARs embedded within the current JAR. The classpath for this classloader is "./" follows by "lib/xyz.jar", where these URLs are resolved within the outer JAR file.JarRsrcLoaderloads the classcom.abc.Masterusing the special class loader.JarRsrcLoadercalls themainmethod forcom.abc.Master, passing the same string array containing the arguments.In short,
Rsrc-Class-Pathis an attribute that theJarRsrcLoaderclass understands, and uses to construct the actual application classpath.In this context, the
Class-Path: .attribute serves no real purpose. Everything needed to runJarRsrcLoaderwill be in the JAR.As a final note, the SpringBoot loading mechanism is similar, but it uses a different non-standard attribute for the application's main class, and puts the application's resources (e.g. JARs) into a particular directory ("/boot-inf") within the main JAR.