• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Henry Leung
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?
 
David O'Meara
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....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic