Java System.loadLibrary 依赖项
我使用的第 3 方 jar 正在尝试使用 System.loadLibrary 加载本机库。我认为正在发生的事情是正在加载的库之一依赖于另一个本机库。在这种情况下,指向 -Djava.library.path 无法正常工作。应用程序站点的说明是将 dll 放入 jre/bin 目录中,但我认为这是一个非常糟糕的主意(尤其是在尝试部署到客户端站点时)。
所以,这个问题实际上是由两部分组成。
如果本机库尝试加载另一个 -Djava.library.path 不起作用的本机库,这是否有意义?
有没有好的解决方案来解决这个问题?我想我可以在所有 dll 上显式调用 System.loadLibrary (我什至不确定这是否有效),但我需要确保以正确的顺序调用它们,否则我会遇到同样的问题。
编辑:我认为这是有道理的,它正在发生,到目前为止我读过的最好的解决方案是使用依赖步行器来找出它,然后以相反的顺序加载它们......但我愿意接受更好的建议。 ..
谢谢, 杰夫
A 3rd party jar I use is trying to load a native library using System.loadLibrary. I think what is happening is that one of the libraries being loaded has a dependency on another native library. Pointing -Djava.library.path does not work properly in this case. The instructions from the app's site is put the dlls in the jre/bin directory, but I think this is a really bad idea (especially when trying to deploy to client sites).
So, this question really is 2 parts.
Does it make sense that if a native lib tries to load another native lib that -Djava.library.path does not work?
Is there a good solution for working around this problem? I guess I could explicitly call System.loadLibrary on all of the dlls (I'm not even sure if this would work), but I would need to make sure to call them in the correct order otherwise I'll have the same problem.
EDIT: I think this makes sense that it is happening, and the best solution I've read so far is to use dependency walker to figure it out and then load them in reverse order...but I'm open to better suggestions...
thanks,
Jeff
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,本机库不使用 Java 属性 -Djava.library.path 链接到其他本机库是有道理的。
一些可能的方法:
Yes, it makes sense that native libraries do not use the Java property -Djava.library.path to link to other native libraries.
Some possible approaches: