Re: Running Java applications with C libraries trough JNI on HP-UX
- From: Gordon Beaton <n.o.t@xxxxxxxxx>
- Date: 17 Nov 2006 12:11:57 GMT
On 17 Nov 2006 03:32:29 -0800, Krystian wrote:
When i load with System.load with full path to the library it is loaded
and works ok.
That means there's nothing wrong with the library you built, and that
it has no unresolved dependencies preventing it from loading properly.
I suspect your use of System.loadLibrary() is wrong. What is the full
name of the library, and what is the argument you pass loadLibrary()?
Can you get it to work by setting (and exporting) SHLIB_PATH?
Try running your program under strace or truss or similar, to see
exactly what file the JVM is searching for. For example, here is what
strace tells me System.loadLibrary("foo") is doing on my Linux system:
$ cat Foo.java
public class Foo {
public static void main(String[] args) throws Exception {
System.out.println("java.library.path contains:");
System.out.println(System.getProperty("java.library.path"));
System.out.println();
System.loadLibrary("foo");
}
}
$ strace -o strace.txt java Foo
java.library.path contains:
/usr/local/pgm/jdk1.5.0_09/jre/lib/i386/client:/usr/local/pgm/jdk1.5.0_09/jre/lib/i386:/usr/local/pgm/jdk1.5.0_09/jre/../lib/i386
Exception in thread "main" java.lang.UnsatisfiedLinkError: no foo in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:993)
at Foo.main(Foo.java:7)
Afterwards, strace.txt contains:
[...]
stat64("/usr/local/pgm/jdk1.5.0_09/jre/lib/i386/libfoo.so", 0xfeffcc68) = -1 ENOENT
stat64("/usr/local/pgm/jdk1.5.0_09/jre/lib/i386/client/libfoo.so", 0xfeffcc68) = -1 ENOENT
stat64("/usr/local/pgm/jdk1.5.0_09/jre/lib/i386/libfoo.so", 0xfeffcc68) = -1 ENOENT
stat64("/usr/local/pgm/jdk1.5.0_09/jre/../lib/i386/libfoo.so", 0xfeffcc68) = -1 ENOENT
[...]
write(2, "Exception in thread \"main\" ", 27) = 27
write(2, "java.lang.UnsatisfiedLinkError: "..., 59) = 59
/gordon
--
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
.
- Follow-Ups:
- References:
- Running Java applications with C libraries trough JNI on HP-UX
- From: Krystian
- Re: Running Java applications with C libraries trough JNI on HP-UX
- From: Gordon Beaton
- Re: Running Java applications with C libraries trough JNI on HP-UX
- From: Krystian
- Re: Running Java applications with C libraries trough JNI on HP-UX
- From: Gordon Beaton
- Re: Running Java applications with C libraries trough JNI on HP-UX
- From: Krystian
- Running Java applications with C libraries trough JNI on HP-UX
- Prev by Date: Re: Problem with regular expressionsq
- Next by Date: Re: About FileXXXputStream 's implementation
- Previous by thread: Re: Running Java applications with C libraries trough JNI on HP-UX
- Next by thread: Re: Running Java applications with C libraries trough JNI on HP-UX
- Index(es):
Relevant Pages
|