Native Library already loaded in another classloader [duplicate]

隐身守侯 提交于 2019-12-01 04:35:07

In short, the same instance of the class that uses the native library must be shared by both classes.

You can do this by getting the system class loader (or the top parent of the class loader of your current class) and then dynamically have it load the class which uses the native library.

If you don't know which class does load the native library then you can make a proxy class and load this isntead. The class must call to the other libraries for you so they will be loaded with the Proxy classes classloader (and so also be shared).

However I would expect the security manager to prevent you from doing this within an Applet.

There is no point in loading the Native Library(as a matter of fact any library)twice in different locations. You can make Applet1's *driver* object as static.
And use it in Applet2.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!