I'm trying to find a way to support 2 different versions of an API in my code base. They have the same package names but work much differently under the hood (two completely different systems). How can I do this?
Both of these API's also have a dependency on Bouncy Castle but they use different versions of it. How do I also take this into account?
I would not recommend this unless you know what you're doing but you could use a URLClassLoader as follows:
URLClassLoader classLoaderA = URLClassLoader.newInstance(new URL[] {new URL("versionA.jar")});
URLClassLoader classLoaderB = URLClassLoader.newInstance(new URL[] {new URL("versionB.jar")});
Load the class:
classLoaderA.loadClass("SomeClass");
Another option is to have a look at OSGI.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With