Answer to UnsatisfiedLinkError - JNI

S

sharad nangia

Hello,

I was facing problems with JNI such as "Exception in thread "main"
java.lang.UnsatisfiedLinkError" on solaris 8. Even after a futile
search on various discussion boards, there was no answer to the
problem, so with a little R&D here is a solution to the problem ..
though not sure whether people are already aware and havent posted
answer.

This is true for solaris machines only and havent tested for windows
or other OS.

1. Firstly make sure that directory which contains the so (shared
object) file is already contained in LD_LIBRARY_PATH.

2. There is a naming convention which needs to be followed. When u
compile your C or C++ code to a shared object (say listfiles.so)
prefix it with lib (i.e liblistfile.so) ..this is mandatory to do so.
However ur java calling program would load the library (with name
without the lib (i.e listfiles.so)), failing to comply to this u would
definately get UnsatisfiedLink error.

Inshort..

java code would have something like this ..

System.loadLibrary(listfiles)

and the shared object would be named as (liblistfiles.so)

directory which contains liblistfiles.so is
/home/sharad/lib/liblistfiles.so

in ksh shell -

export LD_LIBRARY_PATH=/home/sharad/lib:$LD_LIBRARY_PATH

hope the above information is useful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,913
Messages
2,570,027
Members
46,421
Latest member
WaylonBran

Latest Threads

Top