From owner-freebsd-java@FreeBSD.ORG Sun Feb 8 10:20:26 2004 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E40AC16A4CE for ; Sun, 8 Feb 2004 10:20:26 -0800 (PST) Received: from limicola.its.uu.se (limicola.its.uu.se [130.238.7.33]) by mx1.FreeBSD.org (Postfix) with ESMTP id 13CEC43D1D for ; Sun, 8 Feb 2004 10:20:26 -0800 (PST) (envelope-from yuri@irfu.se) Received: by limicola.its.uu.se (Postfix, from userid 205) id 88F8E5B02B; Sun, 8 Feb 2004 19:20:24 +0100 (MEZ) Received: from limicola.its.uu.se(127.0.0.1) by limicola.its.uu.se via virus-scan id s2185; Sun, 8 Feb 04 19:20:16 +0100 Received: from irfu.se (sol.irfu.se [130.238.30.6]) by limicola.its.uu.se (Postfix) with SMTP id 2B66A5B81B; Sun, 8 Feb 2004 19:20:16 +0100 (MEZ) Received: from irfu.se by irfu.se (SMI-8.6/SMI-SVR4) id TAA21541; Sun, 8 Feb 2004 19:20:27 +0100 Message-ID: <40267E19.9040605@irfu.se> Date: Sun, 08 Feb 2004 19:21:13 +0100 From: Yuri Khotyaintsev Organization: Swedish Inst. of Space Physics User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; uk-UA; rv:1.6) Gecko/20040113 X-Accept-Language: uk-UA, uk, ru, sv MIME-Version: 1.0 To: "Daniel R. Curran" References: <40267815.5000508@cs.rit.edu> In-Reply-To: <40267815.5000508@cs.rit.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-java@freebsd.org Subject: Re: JNI Share Library Issue X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Feb 2004 18:20:27 -0000 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 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.(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