In Java, how can I create a ClassLoader which will use a particular classpath (probably just a single jar file)?
A:
Indeed, create a URLClassLoader as pointed out by @bmargulies. It's pretty easy to use, just pass an array of URLs into the constructor.
Maybe also check this thread and, in particular, this post for some tips on how to use Java (hierarchical) ClassLoaders. I don't know what you want to do exactly but you may find it useful.
Pascal Thivent
2010-01-12 14:24:48