JNI Share Library Issue
Yuri Khotyaintsev
yuri at irfu.se
Sun Feb 8 10:20:27 PST 2004
You cannot load a native FreeBSD library into Linux JDK.
You have to use a native JDK with this library, or install
linux_devtools port and compile a Linux shared library.
Best,
Yuri
Daniel R. Curran wrote:
> 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
> _______________________________________________
> freebsd-java at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-java
> To unsubscribe, send any mail to "freebsd-java-unsubscribe at freebsd.org"
>
>
--
Yuri Khotyaintsev, PhD
Swedish Institute of Space Physics, http://www.cluster.irfu.se/yuri
Uppsala Division (IRF-U) http://ovt.irfu.se
More information about the freebsd-java
mailing list