I use RedHat 6.1 and JDK1.2.2 RC1
I have 2 kind of problemes with the JNI.

First I get an exception with the following code.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Hello
        at Native.main(Native.java:14)

// Here is Native.java

public class Native {

  static {
    System.loadLibrary("Native");
    }

  public Native() {
    }

  public native void Hello();

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

// Here is Native.c

#include <iostream.h>
#include <jni.h>

JNIEXPORT
void
JNICALL
Java_Native_Hello (JNIEnv * env, jobject object)
  {
  cout << "Hello World !" << endl;
  }

Second, I get a segmentation fault on the JNI_CreateJavaVM call of the
following code.
Am i missing something ?

// Here is Invoke.cpp

#include <stdlib.h>
#include <iostream.h>
#include <jni.h>

int main(int argc, char **argv)
  {
  JavaVM * jvm;
  JNIEnv * env;
  JavaVMInitArgs vm_args;
  JNI_GetDefaultJavaVMInitArgs ( &vm_args );
  jint res = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
  if (res < 0)
    {
    cerr << "Can't start JavaVM" << endl;
    exit(1);
    }
  cout << "Java VM Started" << endl;
  jvm->DestroyJavaVM();
  }

Pierre




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

Reply via email to