JNI Share Library Issue
Daniel R. Curran
drc7257 at cs.rit.edu
Sun Feb 8 09:49:09 PST 2004
I am trying to learn how to use JNI and I started with the Java JNI
tutorial <http://java.sun.com/docs/books/tutorial/native1.1/> and was
quickly lead around the web by google trying to figure out how to
construct a proper shared library. I have searched and have not found
anything suggesting information different than what I am doing.
I am trying to simply get the HelloWorld demo to work.
Some basic info:
java -version
java version "1.3.1_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_10-b03)
Classic VM (build 1.3.1_10-b03, green threads, nojit)
file libhello.so
libhello.so: ELF 32-bit LSB shared object, Intel 80386, version 1
(FreeBSD), not stripped
The commands I use to create and run the java program are:
javac HelloWorld.java
javah -jni HelloWorld
cc -fPIC -Wall -c HelloWorldImp.c
-I/usr/local/linux-sun-jdk1.3.1/include
-I/usr/local/linux-sun-jdk1.3.1/include/linux
ld -Bshareable -fPIC -o libhello.so HelloWorldImp.o
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD
java HelloWorld
Everything is working fine until I get to the java HelloWorld call,
which results in the following runtime exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
/usr/home/dan/programming/jni/libhello.so:
/usr/home/dan/programming/jni/libhello.so: ELF file OS ABI invalid
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1414)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1338)
at java.lang.Runtime.loadLibrary0(Runtime.java:744)
at java.lang.System.loadLibrary(System.java:815)
at HelloWorld.<clinit>(HelloWorld.java:5)
I thought that I was doing everything correctly, but I must not be. Does
anyone have any idea as to how I can get this to work?
Thanks,
Dan Curran
More information about the freebsd-java
mailing list