Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Package referenced jars into one

 
Corne Vermeulen
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 199
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 199
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Carles,

Thanks for the info! You wouldn't happen to know how to load classes into the class path?
 
Carles Gasques
Ranch Hand
Posts: 199
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, will give that a try!

I appreciate the help!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic