Source of MsgImpl.cpp


  1: //: appendixb:MsgImpl.cpp
  2: //# Tested with VC++ & BC++. Include path must 
  3: //# be adjusted to find the JNI headers. See 
  4: //# the makefile for this chapter (in the 
  5: //# downloadable source code) for an example.
  6: #include <jni.h>
  7: #include <stdio.h>
  8: #include "ShowMessage.h"

 10: extern "C" JNIEXPORT void JNICALL 
 11: Java_ShowMessage_ShowMessage(JNIEnv* env, 
 12: jobject, jstring jMsg) {
 13:   const char* msg=env->GetStringUTFChars(jMsg,0);
 14:   printf("Thinking in Java, JNI: %s\n", msg);
 15:   env->ReleaseStringUTFChars(jMsg, msg);
 16: } ///:~