Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Jul 1999 22:06:34 -0600
From:      "E. Scott Larsen" <larsene@bahay.rn.byu.edu>
To:        freebsd-java@freebsd.org
Subject:   jni
Message-ID:  <379FD34A.DEBADA13@bahay.rn.byu.edu>

next in thread | raw e-mail | index | archive | help
I'm looking into using the JNI for an upcoming project, and hava a
question about using on
FreeBSD.  I'm doing a very simple example (code for each file is below)
from the Essential
JNI (Rob Gordon, Prentace Hall...).  I'm running  FreeBSD-3.2-Stable
about a week old;
jdk1.1.8 just re-installed fresh this morning from cvsup'd ports, and
using the csh:

> cd /home/larsene/jni
> setenv LD_LIBRARY_PATH /home/larsene/jni:/usr/lib:/usr/local/lib
> rm *.o lib*
> g++ -c -fPIC *.c -I$JDK/include -I$JDK/include/freebsd
> g++ -shared -o libmylib.so -fPIC *.o
> java main
/usr/lib/libg++.so.4: Undefined symbol "__pure_virtual" (libmylib.so)
my error
>
I assume the problem is something missing from that LD..PATH setting, or
perhaps a
compiler flag.  Anyone got a quick tip or a pointer to somewhere I aught
to look?  Thanks
tons!!!

// file: main.java
public class main {
         static {
                  try {
                                System.loadLibrary("mylib");
                  } catch (Error e) {
                                System.out.println("my error");
                                System.exit(0);
                  }
         }
         public static void main(String[] args) {
                  aclass        c = new aclass();
                  c.theNativeMethod();
         }
}
//file: aclass.java
public class aclass {
         public native void theNativeMethod();
         public void aJavaMethod() {
                  theNativeMethod();
         }
}
//file: aclass.c
#include <stdio.h>
#include "aclass.h"
JNIEXPORT void JNICALL  Java_aclass_theNativeMethod
         (JNIEnv* env, jobject thisObj)  {
         printf("Hello Scott World\n");
}
//file: aclass.h  ////generated by >javac aclass.java ; javah -jni
aclass
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class aclass */
#ifndef _Included_aclass
#define _Included_aclass
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     aclass
 * Method:    theNativeMethod
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_aclass_theNativeMethod
  (JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?379FD34A.DEBADA13>