本机库已加载到另一个类加载器中 [英] Native Library already loaded in another classloader

查看:35
本文介绍了本机库已加载到另一个类加载器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助来处理以下情况.

I need some help to handle following scenario.

我正在使用两个需要相同本机库 (.dll) 文件的小程序.

I am using two applets which requires the same native library (.dll) file.

因此,当我从网页运行小程序时,第一次小程序将 dll 加载到小程序类加载器中.它工作正常.但是当第二个小程序尝试加载相同的 dll 时,它给了我一个异常,说 加载 win32com 时出错:java.lang.UnsatisfiedLinkError:本机库 C:\WINDOWS\system32\win32com.dll 已经加载到另一个类加载器中"

So when I run the applets from the web pages, for the first time first applet loads the dll into the applet class loader. It works fine. But when second applet tries to load the same dll it gives me exception saying that "Error loading win32com: java.lang.UnsatisfiedLinkError: Native Library C:\WINDOWS\system32\win32com.dll already loaded in another classloader"

我使用以下方法加载驱动程序.

I using following method to load the driver.

CommDriver driver = (CommDriver)Class.forName("com.sun.comm.Win32Driver").newInstance();
driver.initialize();

请给我解决方案

谢谢&Rgds,瑞诗凯诗

Thanks & Rgds, Rishikesh

推荐答案

在不同位置两次加载 Native Library(实际上是任何库)是没有意义的.您可以将Applet1 的 *驱动程序* 对象设为静态.
并在 Applet2 中使用它.

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.

这篇关于本机库已加载到另一个类加载器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆