From owner-freebsd-java@FreeBSD.ORG Sun Feb 8 09:49:09 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 7EDE716A4CE for ; Sun, 8 Feb 2004 09:49:09 -0800 (PST) Received: from host7.globalnameservers.com (host7.globalnameservers.com [209.239.34.25]) by mx1.FreeBSD.org (Postfix) with ESMTP id 447A043D1D for ; Sun, 8 Feb 2004 09:49:09 -0800 (PST) (envelope-from drc7257@cs.rit.edu) Received: from cs.rit.edu (roc-66-67-196-34.rochester.rr.com [66.67.196.34]) i18Hn8hu009986 for ; Sun, 8 Feb 2004 12:49:08 -0500 Message-ID: <40267815.5000508@cs.rit.edu> Date: Sun, 08 Feb 2004 12:55:33 -0500 From: "Daniel R. Curran" User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.6b) Gecko/20031210 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-java@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: 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 17:49:09 -0000 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