开发者

How to debug a problem when loading native libs in Java?

I have a problem relative to JNI and Java. Here is the thing : the client wants us to install a certain app on his system. This app uses native libs, but the client does not want to put these libs in his system folder, for reasons I don't really know or unders开发者_如何转开发tand, but can't change.

To circumvent thius problem, I tried to launch the JVM with -Djava.library.path, putting the right dlls in it. But the fact is, I have a UnsatisfiedLinkError when I try to launch my project. From what I can see, the problem is not in the main dll called (because the file obviously exists, I saw it when debugging), I think that must be some of the libs linked by this first dll that are problematic, but I don't know how to find what dll is missing.

Any idea on how to solve this problem ?


My first port of call (even for JNI debugging) is always Dependency Walker. If nothing else, it will tell you every other DLL that your DLL depends on.

ldd is the equivalent for Linux.


I think that parameter is for specifying directories, not files. So if your dll is c:\mylibs\lib1.dll then you have to set its value to c:\mylibs.

I don't know if it allows multiple paths. Let me check.

Edit

That parameter do allow multiple paths.

See section 2.7 in http://java.sun.com/docs/books/jni/html/start.html

It doesn't specify the format but I imagine you can use the same separator than in classpath. It says you can also use the PATH system variable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜