Solved

How to resolve Native code library failed to load.

Posted on 2010-11-12
8
3,622 Views
Last Modified: 2012-05-10
My Java application when run thru the batch file, is throwing below error:

Native code library failed to load.
java.lang.UnsatisfiedLinkError: 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
0
Comment
Question by:MehtaJasmin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 16

Expert Comment

by:Valeri
ID: 34124007
These wrappers are placed in dll file. I'm not so familiar with eclipse, but in JIDEA when I start a program with "run" it shows the command line... so compare this command line with the one from your batch file.
probably you have to add this to your java command in your batch file -Dlibrary.path=/pathToTheDLLLibrary/yourDll.dll
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34124105
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"));

Open in new window

0
 
LVL 16

Expert Comment

by:Valeri
ID: 34124765
ops, sorry, I missed java. so it should be
-Djava.library.path=/pathToTheDLLLibrary/yourDll.dll
also this could help you somehow:
http://www.inonit.com/cygwin/jni/helloWorld/load.html
0
Put Machine Learning to Work--Protect Your Clients

Machine learning means Smarter Cybersecurity™ Solutions.
As technology continues to advance, managing and analyzing massive data sets just can’t be accomplished by humans alone. It requires huge amounts of memory and storage, as well as the high-speed power of the cloud.

 
LVL 92

Expert Comment

by:objects
ID: 34125190
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
0
 

Author Comment

by:MehtaJasmin
ID: 34136412
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.library.path :" + System.getProperty("java.library.path"));

It came up with below directory structure as far as windows libraries
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\WINDOWS\system32\nls;
C:\WINDOWS\system32\nls\ENGLISH;C:\WINDOWS\system32\WindowsPowerShell\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\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\WINDOWS\system32\nls;C:\WINDOWS\system32\nls\ENGLISH
java -Djava.library.path="%PATH%" com.nex.fuelsale.NEXFuelSaleRSAEncryption %*1 %*2 %*3 %*4 %5


Also tried loading the library explicitly by adding
System.loadLibrary("LBJNIWrappers");
in main() method. But still getting this exception.

Exception in thread "main" java.lang.UnsatisfiedLinkError: no LBJNIWrappers in j
ava.library.path
        at java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.lang.Runtime.loadLibrary0(Unknown Source)
        at java.lang.System.loadLibrary(Unknown Source)
        at com.nex.fuelsale.NEXFuelSaleRSAEncryption.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.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 34136636
>>It came up with below directory structure as far as windows libraries

And what about the non C:\Windows\* directories? They need to be on java.library.path too
0
 

Author Closing Comment

by:MehtaJasmin
ID: 34137031
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\OracleAS_3\BIN" directory where "D:\product\10.1.3.1\OracleAS_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\system32;D:\product\10.1.3.1\OracleAS_3\BIN
java com.nex.fuelsale.NEXFuelSaleRSAEncryption %*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.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34137082
:)
0

Featured Post

Automating Your MSP Business

The road to profitability.
Delivering superior services is key to ensuring customer satisfaction and the consequent long-term relationships that enable MSPs to lock in predictable, recurring revenue. What's the best way to deliver superior service? One word: automation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
V.simple question about Android packages and libraries 1 44
Oracle encryption 12 70
Java Restore security prompts not working 10 236
batch vs regular insert in spring DAO 2 47
SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question