Issue while loading a dll library file… java.lang.UnsatisfiedLinkError: Can't load library

。_饼干妹妹 提交于 2020-01-02 02:20:10

问题


While loading a dll file, I am getting the following exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError:
  D:\Transliteration\rlpnc-3.1.0-sdk-ia32-w32-msvc80\rlp\bin\ia32-w32-msvc80\btrntjni.dll: 
  The system cannot find message text for message number 0x%1 in the message file for %2

at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.basistech.util.internal.Native.loadLibrary(Unknown Source)
at com.basistech.rnt.jni.<clinit>(Unknown Source)
at com.basistech.rnt.RNTEnvironment.<init>(Unknown Source)
at SampleTranslator.<init>(TranslateNameSample.java:88)
at TranslateNameSample.main(TranslateNameSample.java:62)

not sure about the root cause of the issue. Can anybody help me out in resolving this issue.

Thanks, Bhaskar


回答1:


I work for the company that makes the product you're trying to use. We've seen this error when it's been installed against an incompatible version of the underlying layer we ship with it, because of missing dependent DLLs as others have suggested. Feel free to contact our support team for more help.




回答2:


This does not have to do anything with the classpath. Place the DLL in the current directory, in one of the directories listed in the PATH environment variable, or, best of all, in the native library search path, set using the system property java.library.path:

java -Djava.library.path=C:\MyNativeLibs MyMainClass



回答3:


As well as checking your are putting the path to the DLL in the correct environment variable you should also check the following:

  • The DLL you are loading has all its dependencies satisfied. In other words, if this DLL depends on other DLLs, make sure those DLLs can also be found.

  • If the DLL being loaded uses a manifest to specify a specific DLL, ensure that DLL (of the version specified in the manifest) is also on the machine (or in the GAC, if required) and can be found

  • Check that all DLL functions referred in your Java code are correctly defined and exported and export the same datatypes as those your Java code is expecting. This won't stop the DLL loading, but it may well mess up the next stage - resolving link addresses or making functions that should work, fail in unexpected ways.

Lots of fun to be had with this - lots of little things to trip you up. I had to deal with this a few years back messing with a text to speech package (in C & C++ in a DLL) working with different versions of Java with old and new JNI styles. What a mess!




回答4:


I have not seen this problem myself, but from the error message it sounds like some dependency needed by the DLL is either missing or incorrect version.

This tool might help: http://www.dependencywalker.com/




回答5:


For me, adding the dll path to the VM options in my IDE worked.




回答6:


Check that the "java.library.path" contains the folder containing .dll file.
On windows machine it is related to PATH.
http://www.inonit.com/cygwin/jni/helloWorld/load.html



来源:https://stackoverflow.com/questions/2407395/issue-while-loading-a-dll-library-file-java-lang-unsatisfiedlinkerror-cant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!