Pierre Héroux wrote:
>
> 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 ?
It sounds like you needed 'extern "C"' somewhere in your native code
implementation file. Do a 'nm libNative.so' and make sure a function
symbol 'Java_Native_Hello' is exported, not some C++ decorated variant.
--
Weiqi Gao
[EMAIL PROTECTED]
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]