JNI依赖库 [英] JNI dependent libraries

查看:103
本文介绍了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天全站免登陆