Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_java thread: jni calling into mfc


Message #1 by "Nick Tucker" <nick.tucker@s...> on Thu, 27 Sep 2001 18:08:19
Hi all,
    I have a java class called DisplayMessage that looks like so:

public class DisplayMessage {
  static {
    System.out.println("Load DisplayMessage.dll" );
    System.loadLibrary("WinNativeSoapHandler");
    System.out.println("Loaded DisplayMessage.dll" );
  }
  public static void main(String[] args) {
    System.out.println("Call printMessage" );
    printMessage();
  }
  public static native void printMessage();
}

I have created a MFC project that I put in the following simple funtion:

JNIEXPORT void JNICALL Java_DisplayMessage_printMessage
     (JNIEnv *env, jclass cl)
{
  printf("Frank");
}

But when I run it I get the following output

Load DisplayMessage.dll
Loaded DisplayMessage.dll
Call printMessage
Exception in thread "main" java.lang.UnsatisfiedLinkError: printMessage
        at DisplayMessage.printMessage(Native Method)
        at DisplayMessage.main(DisplayMessage.java:11)

I created a simple Win32 DLL project and it all worked ok so my question
is:  Can I use JNI to call into a MFC project or does it have to be a
Win32 DLL??  Are there any ways around this?

Thanks for any help,
Nick


  Return to Index