I am writing Plugin for some Application. Lets suppose that Application hava library dependency of libA-1.0 and my plugin has similar dependency of libA-2.0. There are different in versions and are not compatible each other (i.e. they have different api method signatures).
How to prevent my Plugin from loading classes from libA-1.0 (or how to force it to use classes from libA.2.0)?
Is there any way to do this not writing custom classloader and not using forName, loadClassDefinition calls?
The similar problem occurs when you put some libraries to *.war archive and they do not load becouse web containter has "the same" libraries on classpath.
Thaks for any help.
Regards, Paweł
OSGI provides this functionality out of the box. I'm sure there are some other plugin frameworks that provide similar functionality.
There is a URLClassLoader which should be able to provide a lot of the functionality of loading classes from a different jar. You'll have to put in some effort to change the class loader of the Threads that are doing the work. Don't have an example on hand, would have to write one if you need a concrete example (unless you can find one with a search engine)