java.lang.UnsatisfiedLinkError: no HelloWorldImp in java.library.path

Hello,

I have written a small C function to display HelloWorld message. I am calling the C function from a java program through JNI.

The program is working fine under HP UX 11.11 system. But the program is not working under HP-UX11.23(v2).

Could you please let us know why this is happening?

Please find the steps I followed in detail:

i)a sample java class with a native method declaration

ii) a C function which displays HelloWorld message

iii) compiled the java file

iv) generated header file with javah tool

v) compiled the C function

vi) created the shared library

Note: The same steps are being followed in both the machines

Compiling options:

/usr/bin/cc -Ae +u4 -D_HPUX -c +DA1.1 +z -I. -I/opt/java1.4/include -I/opt/java1.4/include/hp-ux HelloWorldImp.c HelloWorldImp.o

command used to create shared library:

/usr/bin/ld -b -o ./libHelloWorldImp.sl ./HelloWorldImp.o

vii) exported SHLIB_PATH

Any help in this regard will be more helpful.

Please let us know in case of any change in compiler options. Please let me know in case of any questions.

Thanks and Regards,

Jnanprasad

[1216 byte] By [jnanprasadchukka@tcsa] at [2007-11-26 23:44:23]
# 1
The error says that it didn't find the shared library. It doesn't say anything about having a problem loading it. So compiler options have nothing to do with it.I would guess that you are using different shells - that means different ways to specify the shared library path.
jschella at 2007-7-11 15:15:48 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

Hi,

Thanks for your feedback...

In the static block, I have put two print statements before and after System.loadLibrary statement.

the print statement before the loadLibrary is being executed.

But the print statement after the loadLibrary is not executed. Also I am confiming that shells in both the machines are same(ksh).

Regards,

Prasad.

jnanprasadchukka@tcsa at 2007-7-11 15:15:48 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3

> Hi,

>

> In the static block, I have put two print statements

> before and after System.loadLibrary statement.

> the print statement before the loadLibrary is being

> executed.

> But the print statement after the loadLibrary is not

> executed.

Not sure why you think that would help. The library fails to load so an exception is thrown. You already knew that. Your code change does nothing but demonstrate that.

Print out the java.lang.path properties value inside your running application before you load the library. That MUST have the full path to the shared library location. If it doesn't then your environment is wrong.

If it does then you might want to confirm the extension of the library that you are attempting to load.

jschella at 2007-7-11 15:15:48 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 4
Hi,I tried the other option like libXXX.so.Now it is working.. Thanks a lot..Regards,prasad.
jnanprasadchukka@tcsa at 2007-7-11 15:15:48 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 5
I got the java.lang.UnsatisfiedLinkError:HelloWorld in java
krishnavga_slma at 2007-7-11 15:15:48 > top of Java-index,Java HotSpot Virtual Machine,Specifications...