• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to load a Jar Library dynamically?  RSS feed

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We all know that the System and Runtime classes have methods to load native libraries ( *.dll or *.so ). But I would like to know whether there is any way to load a Jar ( Java Archive ) library into the JVM as a library at runtime? Thanks in advance for your assistance.
Regards,
Siddhartha
 
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "load a jar file dynamically at runtime" - add it to the classpath after the JVM has started up? I don't think you can alter the classpath of the system classloader, but you could develop your own classloader that can handle a classpath that changes during runtime, or that knows how to deal with jar files that get added to a directory after the initial setup.
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to play with classloaders. please take a look to this example.
http://javaalmanac.com/egs/java.lang/LoadClass.html?l=rel
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!