JNI 依赖库 [英] JNI dependent libraries

查看:27
本文介绍了JNI 依赖库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过 JNI 运行一个库(我没有编写它),并且在内部它调用了另一个 DLL.除非我将另一个 DLL 的路径放在系统 PATH 变量上(我在 Windows XP 上),否则我会收到一条错误消息找不到依赖库".我希望能够在 java 命令行上处理这个问题,我已经尝试将它添加到 -Djava.library.path 和类路径中,但都没有工作(我希望 -Djava.library.path 工作但不是类路径,但都没有工作).有没有办法做到这一点?

I'm running a library via JNI (I didn't write it), and internally it calls another DLL. I get an error saying "Can't find dependent libraries" unless I put the path of the other DLL on the system PATH variable (I'm on Windows XP). I'd like to be able to handle this on the java command line, and I've already tried adding it to -Djava.library.path and to the classpath, neither which worked (I expected -Djava.library.path to work but not classpath, but neither worked). Is there a way to do this?

谢谢,

杰夫

推荐答案

  • 如果您的 DLL 名称为MyNativeDLL.dll",那么您应该在 LoadLibrary 调用中使用MyNativeDLL".
  • 使用Dependency Walker检查是否有MyNativeDLL.dll需要的文件
  • 如果有,请将它们包含在与 MyNativeDLL.dll 相同的文件夹中 - 你可以尝试将其他所需文件放入 System32 文件夹中.
    • If you have a DLL name 'MyNativeDLL.dll' then you should use 'MyNativeDLL' in your LoadLibrary call.
    • Use Dependency Walker to check if there are any files required by MyNativeDLL.dll
    • If there are, include them in the same folder as MyNativeDLL.dll - one you get it working try putting the additional required files in System32 folder.
    • 这篇关于JNI 依赖库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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