views:

430

answers:

5

Hi,

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

A: 
Padmarag
Yes, it contains but still the issue comes up :(
Bhaskara Krishna Mohan Potam
Please post the complete CLASSPATH
Padmarag
Here it goes.. D:\apache-ant-1.8.0\lib;D:\Transliteration\rlp-6.5.0-sdk-ia32-w32-msvc80\rlp\lib\ia32-w32-msvc80;D:\Transliteration\rlpnc-3.1.0-sdk-ia32-w32-msvc80\rlp\lib\ia32-w32-msvc80;D:\Transliteration\rlpnc-3.1.0-sdk-ia32-w32-msvc80\rlpnc\samples\java;D:\Transliteration\rlp-6.5.0-sdk-ia32-w32-msvc80\rlp\bin\ia32-w32-msvc80;D:\Transliteration\rlpnc-3.1.0-sdk-ia32-w32-msvc80\rlp\bin\ia32-w32-msvc80;.
Bhaskara Krishna Mohan Potam
Agree with Dmitry, JRE does not use the CLASSPATH to look for native libraries .. it uses the library path.
BryanD
My Bad. It should be "Java library path". For windows it includes PATH - http://www.inonit.com/cygwin/jni/helloWorld/load.html Updating answer.
Padmarag
The dll directory is already included in PATH env variable but that doesn't make any difference. Issue still exists
Bhaskara Krishna Mohan Potam
A: 

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
Dmitry Leskov
The directory is already listed in the PATH env variable. But still I am getting this error. To make this simple, here is the code I am trying to run.. public class testClass { public static void main(String[] args) { System.loadLibrary("btrntjni"); }}
Bhaskara Krishna Mohan Potam
The following exception is coming up.. Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\Transliteration\rlpnc-3.1.0-sdk-ia32-w32-msvc80\rlpnc\samples\java\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.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at testClass.main(testClass.java:7)
Bhaskara Krishna Mohan Potam
+1  A: 

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!

Stephen Kellett
+1  A: 

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/

fish
A: 

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.

dmurga