• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using different versions of jar files

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two version of my jar file in jboss lib folder. Can I use API's of both the jar files as and when needed from my war file? If yes then how will I differentiate in the code for which version of jar file to use?

Please let me know if you need more details.

Thanks!
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have no control over which one of the two will be used; it's a bad idea. Why are you doing this?

If you need to support two versions of the API with identical class names, keep the jar files outside of the lib folder, and create your own classloader that knows about them and their differences.
 
P Lavti
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont ahve any idea about creating a customized class loaders.
Can you please tell me some good tutorials and examples available on net, which i can use for my reference.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're not familiar with class loaders, this may be a tall order. The SecurityFaq links to a few articles on the subject; I particularly recommend the first one titled "CLASS LOADERS AS A NAMESPACE MECHANISM".

An alternate solution -if you have a limited number of API versions to support- might be to include the API version somewhere in the package name hierarchy. Then the code would explicitly use different classes (representing different API versions) as appropriate.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic