• 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Can I load classes from a specific jar file at runtime?

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a web-app running on an app-server. The app-server has by default loaded an XML parser, but that's too old for my app. I want to use my own version of xerces.jar but I don't want to modify any server setting. So I wonder if it is possible to specify a file path for the targeted xerces.jar at runtime, let my web-app use that jar file's classes, and overrides the loaded ones by the app-server? Any such tricks can be done in the ClassLoader?
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out java.net.URLClassLoader
You can specify your own ClassLoader then use findResource on that loader to load the files it knows about.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, it seems I misunderstood your question.
Your app has its own version of xerces.jar, but you would like to override this at runtime with your own version of xerces.jar
When you say 'the app server has its own version', you should be able to put your xerces.jsr in the web-inf/lib directory and have it loaded in preference to the one in the application server.
(If you are refering to the deprecated files you may be a able to find a compatibility jar to bridge the gap)
I'm not sure where these jar files are configured, but I hope this helps.
Dave
 
Henry Leung
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by David O'Meara:
OK, it seems I misunderstood your question.
Your app has its own version of xerces.jar, but you would like to override this at runtime with your own version of xerces.jar
When you say 'the app server has its own version', you should be able to put your xerces.jsr in the web-inf/lib directory and have it loaded in preference to the one in the application server.
(If you are refering to the deprecated files you may be a able to find a compatibility jar to bridge the gap)
I'm not sure where these jar files are configured, but I hope this helps.
Dave


The appserver I am using is JRun 3.0, and I found that the one in the application server is loaded in preference to the one in web-inf/lib....
 
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic