path problem (newbie)

Hi...

I created a small program that uses a JNI call. It works fine, but it requires the absolute path to the library Im using (I get this error when I try to use a relative path: Exception in thread "main" java.lang.UnsatisfiedLinkError: Expecting an absolute path of the library: libHelloTablem.so).

So, how do I overcome this problem? I dont want to link the library to my "home", but to the directory where the program is (the executable file and the library are in the same directory).

thanks in advance

[533 byte] By [Leo77a] at [2007-10-3 1:26:28]
# 1

You load libraries either via load() or loadLibrary().

One uses the lib path of the environment. If it isn't set then it doesn't load.

The other uses a real path. It doesn't have to be absolute but it must be meaningful in terms of where the application runs (the current working directory.)

jschella at 2007-7-14 18:23:58 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

I was getting "Unsatisfied Link error" using loadLibrary, so I was using System.load

I solved the problem using this code:

System.load(System.getProperty("user.dir") +

System.getProperty("file.separator") +

System.mapLibraryName("HelloTablem"));

anyway, thanks for the answer

Leo77a at 2007-7-14 18:23:58 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3

First you allways do System.loadLibrary("HelloTablem");

Then typically you have two choices.

Suppose that your libHelloTablem.so native library is located under the /home/leo77 folder

Then you could do:java -Djava.library.path=/home/leo77 YourClass

-or-export LD_LIBRARY_PATH=/home/leo77:$LD_LIBRARY_PATH

java YourClass

Regards

jfbrierea at 2007-7-14 18:23:58 > top of Java-index,Java HotSpot Virtual Machine,Specifications...