how to load different versions of the same class?

This question shows research effort; it is useful and clear

38

This question does not show any research effort; it is unclear or not useful

Show activity on this post.

I have read a lot about Java classloaders, but so far I have failed to find an answer for this simple question:

I have two versions of com.abc.Hello.class in jars v1.jar and v2.jar. I want to use both in my application. What is the simplest way of doing this ?

I don't expect to be that simple, but something along these lines would be awesome :

Classloader myClassLoader = [magic that includes v1.jar and ignores v2.jar]
Hello hello = myclassLoader.load[com.abc.Hello]

And in a different class :

Classloader myClassLoader = [magic that includes v2.jar and ignores v1.jar]
Hello hello = myclassLoader.load[com.abc.Hello]

I would like to avoid using OSGi.

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.125.0. UTC+08:00, 2024-05-05 06:51
浙ICP备14020137号-1 $访客地图$