NEX_Developer
asked on
How to resolve Native code library failed to load.
My Java application when run thru the batch file, is throwing below error:
Native code library failed to load.
java.lang.UnsatisfiedLinkE rror: no LBJNIWrappers in java.library.path
The same Java application, using Run configuration / target thru eclipse works fine. I do not even have LBJNIWrappers class used in any of the library jar.
How can I resolve it? I have kept the classpath identical in batch file as run configuration.
Thanks
Jasmin
Native code library failed to load.
java.lang.UnsatisfiedLinkE
The same Java application, using Run configuration / target thru eclipse works fine. I do not even have LBJNIWrappers class used in any of the library jar.
How can I resolve it? I have kept the classpath identical in batch file as run configuration.
Thanks
Jasmin
Print the value of this in the one that *does* work and see that it's the same in the other
System.out.println(System.getProperty("java.library.path"));
ops, sorry, I missed java. so it should be
-Djava.library.path=/pathT oTheDLLLib rary/yourD ll.dll
also this could help you somehow:
http://www.inonit.com/cygwin/jni/helloWorld/load.html
-Djava.library.path=/pathT
also this could help you somehow:
http://www.inonit.com/cygwin/jni/helloWorld/load.html
Its looking for the shared lib LBJNIWrappers (eg. dll on windows) and cannot find it
you need to copy that where it will find it
eg. in windows system directory on window, or in LD_LIBRARY_PATH in linux
you need to copy that where it will find it
eg. in windows system directory on window, or in LD_LIBRARY_PATH in linux
ASKER
I have gone thru and apply all the possible solutions. But its still not finding the LBJNIWrappers.
I printed the library thru the code when it runs fine with Eclipse
System.out.println("java.l ibrary.pat h :" + System.getProperty("java.l ibrary.pat h"));
It came up with below directory structure as far as windows libraries
C:\WINDOWS\system32;C:\WIN DOWS;C:\WI NDOWS\syst em32\WBEM; C:\WINDOWS \system32\ nls;
C:\WINDOWS\system32\nls\EN GLISH;C:\W INDOWS\sys tem32\Wind owsPowerSh ell\v1.0;I added that in PATH variable of my batch file and used it in commans as shown below:
set PATH=.;%JAVA_HOME%\bin;C:\ WINDOWS\sy stem32;C:\ WINDOWS;C: \WINDOWS\s ystem32\WB EM;C:\WIND OWS\system 32\nls;C:\ WINDOWS\sy stem32\nls \ENGLISH
java -Djava.library.path="%PATH %" com.nex.fuelsale.NEXFuelSa leRSAEncry ption %*1 %*2 %*3 %*4 %5
Also tried loading the library explicitly by adding
System.loadLibrary("LBJNIW rappers");
in main() method. But still getting this exception.
Exception in thread "main" java.lang.UnsatisfiedLinkE rror: no LBJNIWrappers in j
ava.library.path
at java.lang.ClassLoader.load Library(Un known Source)
at java.lang.Runtime.loadLibr ary0(Unkno wn Source)
at java.lang.System.loadLibra ry(Unknown Source)
at com.nex.fuelsale.NEXFuelSa leRSAEncry ption.main (Unknown Source)
I also have manually search thru whole C:\WINDOWS and other subdirectories of it to find the dll but this is not anywhere. So I am not sure where the Eclipse is picking up, how its working? and how the batch file is not working.
In a Run Configuration of Eclipse, I am not even adding any VM arguments at all. All it has is the just the jre6 set as a JAVA_HOME other than application libraries. Which I have it in batch file already.
I printed the library thru the code when it runs fine with Eclipse
System.out.println("java.l
It came up with below directory structure as far as windows libraries
C:\WINDOWS\system32;C:\WIN
C:\WINDOWS\system32\nls\EN
set PATH=.;%JAVA_HOME%\bin;C:\
java -Djava.library.path="%PATH
Also tried loading the library explicitly by adding
System.loadLibrary("LBJNIW
in main() method. But still getting this exception.
Exception in thread "main" java.lang.UnsatisfiedLinkE
ava.library.path
at java.lang.ClassLoader.load
at java.lang.Runtime.loadLibr
at java.lang.System.loadLibra
at com.nex.fuelsale.NEXFuelSa
I also have manually search thru whole C:\WINDOWS and other subdirectories of it to find the dll but this is not anywhere. So I am not sure where the Eclipse is picking up, how its working? and how the batch file is not working.
In a Run Configuration of Eclipse, I am not even adding any VM arguments at all. All it has is the just the jre6 set as a JAVA_HOME other than application libraries. Which I have it in batch file already.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
CHEJ,
Thank you so much for pointing out the ignored part of the PATH. When java.library.path got printed I ignored all other directories thinking LBJNIWrappers.dll can not be anywhere. I went over all other directories from the path looking for that file and it was in "D:\product\10.1.3.1\Oracl eAS_3\BIN" directory where "D:\product\10.1.3.1\Oracl eAS_3" is set as ORACLE_HOME for my PC. This dll is Java JNI Wrapper layer for CST LockBox which got placed in that folder when the connection to RSA was occurred earlier. I was completely unaware of it. But Eclipse was picking up that directory from System PATH.
As soon as I placed that path it worked ! I infect remove all unnecessary WINDOWS path too. So here is my final path:
set PATH=.;%JAVA_HOME%\bin;C:\ WINDOWS\sy stem32;D:\ product\10 .1.3.1\Ora cleAS_3\BI N
java com.nex.fuelsale.NEXFuelSa leRSAEncry ption %*1 %*2 %*3 %*4 %5
I don't even need to set VM argument explicitly --Djava.library.path because the executable is reading the library from PATH variable.
Thank you so much for pointing out the ignored part of the PATH. When java.library.path got printed I ignored all other directories thinking LBJNIWrappers.dll can not be anywhere. I went over all other directories from the path looking for that file and it was in "D:\product\10.1.3.1\Oracl
As soon as I placed that path it worked ! I infect remove all unnecessary WINDOWS path too. So here is my final path:
set PATH=.;%JAVA_HOME%\bin;C:\
java com.nex.fuelsale.NEXFuelSa
I don't even need to set VM argument explicitly --Djava.library.path because the executable is reading the library from PATH variable.
:)
probably you have to add this to your java command in your batch file -Dlibrary.path=/pathToTheD