System.load(PATH_TO_LIB) issue inside java package
Hi all,
sorry if this has been asked somewhere, but I just could not find any answer of it. I simply want to load a library by using System.load(ABSOLUTE_PATH_TO_LIB) and call its native function. I could get this to work if I call this function in a class without having any package to it.
However, when I moved the class into a package, e.g. com.test package, I will get java.lang.UnsatisfiedLinkError exception. I am certain the System.load could still reference to the lib I pointed to, just that the library is not really loaded and resulting in this error when I call the native method. Any help would be greatly appreciated, thanks in advance.
Sudi
[680 byte] By [
sudia] at [2007-10-3 11:56:25]

Try
System.setProperty("java.library.path",System.getProperty("java.library.path")+File.pathSeparatorChar+<The absolute file path here>);
System.loadLibrary("Name of the library");
Does this work?
Unfortunately, this doesn't work. As mentioned on other threads, we can't change the library path during runtime. If I place the .so file I have into existing library path, things will work. but of course, I want to avoid that. Thanks for your help. Sudi
sudia at 2007-7-15 14:31:50 >

Call
System.load(File.pathSeparatorChar+<The absolute file path here>);
because in System.loadLibrary you can pass only the library name and not the path. Put this call to the static block of the class with native methods or somewhere before the first call to this class members.
Message was edited by:
vitallis
Hi, thanks for the reply.
I have found the problem, the problem was not in the System.load, as I mentioned earlier, I can load the library, but I got unsatisfied link error when I call the native function inside a java package.
The reason to this is the C native function actually does not allow me to call the function from a java package. If I want to call it from a package, then I have to regenerate the header file and the C source code, namely every functions gonna have the package name follow, e.g. au_com_siab_java_helloworld. something similiar to that. Too bad, this is an existing library that I am trying to use and I don't have the source code to change. Thanks all.
sudia at 2007-7-15 14:31:50 >
