Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Package referenced jars into one

 
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!
 
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!!
 
Is this the real life? Is this just fantasy? Is this a tiny ad?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic