aspose file tools*
The moose likes Applets and the fly likes Package referenced jars into one Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Package referenced jars into one" Watch "Package referenced jars into one" New topic
Author

Package referenced jars into one

Corne Vermeulen
Greenhorn

Joined: May 09, 2013
Posts: 6
Hi All!! :-)

I currently have a jar which references external jar files in it's manifest file, but these external files don't cache! Only the main one caches..

I know I can package the jar files into the main one, but then they aren't found by the applet!

What can I do?

Thanks In Advance!
Carles Gasques
Ranch Hand

Joined: Apr 19, 2013
Posts: 199
    
    1
Hi,

If you go for packaging the required jars in the main bundle verify the manifest file.

# Jars packaged in the main bundle (the same level of MET-INF directory)
Rsrc-Class-Path: ./ A.jar B.jar
# External jars
Class-Path: /home/user/java/extensions/A.jar /home/user/java/extensions/B.jar




Best regards,

Carles Gasques
Ranch Hand

Joined: Apr 19, 2013
Posts: 199
    
    1
Sorry "Rsrc-Class-Path" is eclipse specific and is not an option in your scenario.
My mistake,

As stated in the reference
Adding Classes to the JAR File's Classpath

you need to write custom code
Note: The Class-Path header points to classes or JAR files on the local network, not JAR files within the JAR file or classes accessible over internet protocols. To load classes in JAR files within a JAR file into the class path, you must write custom code to load those classes. For example, if MyJar.jar contains another JAR file called MyUtils.jar, you cannot use the Class-Path header in MyJar.jar's manifest to load classes in MyUtils.jar into the class path.



Best regards,

Corne Vermeulen
Greenhorn

Joined: May 09, 2013
Posts: 6
Hi Carles,

Thanks for the info! You wouldn't happen to know how to load classes into the class path?
Carles Gasques
Ranch Hand

Joined: Apr 19, 2013
Posts: 199
    
    1
You could get an idea from JarRsrcLoader

"Basically" :-)
the custom class first read your manifest (getManifestInfo), get the URL's of the jars references, then load the URL's to a URLClassLoader and add the loader to the current thread.

Once done, the classes in the packaged jar's will be available to the classes of the main jar.

Cheers,
Corne Vermeulen
Greenhorn

Joined: May 09, 2013
Posts: 6
Thanks, will give that a try!

I appreciate the help!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Package referenced jars into one