Showing posts with label jar. Show all posts
Showing posts with label jar. Show all posts

Friday, 11 January 2008

Add a jar file to Java load path at run time

Sometimes it is necessary to amend the class load path at run time. For example, dynamically adding jar files containing user-configurable JDBC data sources. The way this is done is truly monstrous -- the URL Path format was only revealed when a colleague looked into the Java library sources. Here is a simple example of how this is done jar-loader-src-0.1.jar which, as usual, has an ant build file: just type "ant run" at the shell prompt to compile and run it. You need ant and JDK >= 1.5 for this.