You will probably have to extern "C" the code in your C++ library.  JNI uses C
calling conventions.

Mark




Pierre Héroux <[EMAIL PROTECTED]> on 01/05/2000 03:47:12 AM

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:    (bcc: Mark Delafranier/SYBASE)
Subject:  Problem with JNI



I hava a problem with JNI.
I use RedHat 6.1 and jdk1.2.2.

The following code doesn't work

public class Native {
  static {
    System.loadLibrary("Native");
    System.out.println("The Library is loaded...");
    }

  public Native() {}

  public native void Hello();

  public static void main(String [] args) {
    Native n = new Native();
    n.Hello();
    }
  }

Here is the code for Hello() which is compiled to produce libNative.so

#include <iostream.h>
#include <jni.h>
JNIEXPORT void JNICALL
Java_Native_Hello(JNIEnv * env, jobject object)
  {
  cout << "Hello World !" << endl;
  }

The execution gives
The Library is loaded...
exception UnsatisfiedLinkError : Hello

Does anybody know where is the error ?

Pierre




----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Reply via email to