D
Douglas Jordan
I followed Sun's JNI tutorial and created a HelloWorld program like
theirs. It works just fine using the built-in gcj java, but does not
work using Sun's official java 1.4.2_08 distribution.
In other words:
[~/jni-test]$ /opt/java/j2sdk1.4.2_08/jre/bin/java
-Djava.library.path=. HelloWorld
Exception in thread "main" java.lang.UnsatisfiedLinkError:
/export/home/djordan/jni-test/libhello.so:
/export/home/djordan/jni-test/libhello.so: cannot open shared object
file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1511)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at HelloWorld.<clinit>(HelloWorld.java:5)
[~/jni-test]$ /usr/bin/java -Djava.library.path=. HelloWorld
Hello world!
[~/jni-test]$
I'm using gcc (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4) to build with:
gcc -fPIC -shared -I/opt/java/j2sdk1.4.2_08/include
-I/opt/java/j2sdk1.4.2_08/include/linux HelloWorldImpl.c -o libhello.so
When I do ldd libhello.so I get:
libc.so.6 => /lib64/tls/libc.so.6 (0x0000002a95683000)
/lib64/ld-linux-x86-64.so.2 (0x000000552aaaa000)
My project has a requirement to use Sun's official Java distribution.
Any ideas?
Thanks.
theirs. It works just fine using the built-in gcj java, but does not
work using Sun's official java 1.4.2_08 distribution.
In other words:
[~/jni-test]$ /opt/java/j2sdk1.4.2_08/jre/bin/java
-Djava.library.path=. HelloWorld
Exception in thread "main" java.lang.UnsatisfiedLinkError:
/export/home/djordan/jni-test/libhello.so:
/export/home/djordan/jni-test/libhello.so: cannot open shared object
file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1511)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at HelloWorld.<clinit>(HelloWorld.java:5)
[~/jni-test]$ /usr/bin/java -Djava.library.path=. HelloWorld
Hello world!
[~/jni-test]$
I'm using gcc (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4) to build with:
gcc -fPIC -shared -I/opt/java/j2sdk1.4.2_08/include
-I/opt/java/j2sdk1.4.2_08/include/linux HelloWorldImpl.c -o libhello.so
When I do ldd libhello.so I get:
libc.so.6 => /lib64/tls/libc.so.6 (0x0000002a95683000)
/lib64/ld-linux-x86-64.so.2 (0x000000552aaaa000)
My project has a requirement to use Sun's official Java distribution.
Any ideas?
Thanks.