I have fixed my problem. I forgot to include the Native.h file produced by javah
which includes the extern "C".

Pierre.

Mark Delafranier wrote:

> You will probably have to extern "C" the code in your C++ library.  JNI uses C
> calling conventions.
>
> Mark
>
> 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;
>   }


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

Reply via email to