Adding JARs to the classpath at runtime?
I have an JAVA application with a plugin-architecture. Each plugin is described in a config file that tells the application in which JAR the plugin is found etc.
My problem is this: some plugins need additional JARs on the classpath. E.g. the plugin might need the mysql jdbc JAR on the classpath.
What do I have to do to dynamically add a couple of JAR URLs to the classpath so that the system class loader can automatically load from these additional JARs?
I experimented with using my own URL classloader, but the problem I face is this: I add a JAR with addURL and later want to e.g. use the JDBC jar or the javax.script.* libraries to do stuff. Internally, the objects from these libraries want to load classes from the CLASSPATH, but it seems my previous addURL call did not accomplish this.
Either I am still missing some important points here or this has to be done differently.