Date: Sun, 08 Feb 2004 19:21:13 +0100 From: Yuri Khotyaintsev <yuri@irfu.se> To: "Daniel R. Curran" <drc7257@cs.rit.edu> Cc: freebsd-java@freebsd.org Subject: Re: JNI Share Library Issue Message-ID: <40267E19.9040605@irfu.se> In-Reply-To: <40267815.5000508@cs.rit.edu> References: <40267815.5000508@cs.rit.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
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@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-java > To unsubscribe, send any mail to "freebsd-java-unsubscribe@freebsd.org" > > -- Yuri Khotyaintsev, PhD Swedish Institute of Space Physics, http://www.cluster.irfu.se/yuri Uppsala Division (IRF-U) http://ovt.irfu.se
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40267E19.9040605>