#include "HelloWorld.h" 
#include <windows.h> 

class utf_chars 
{ 
public: 
  utf_chars(JNIEnv *env, jstring s) 
    : env_(env), s_(s), c_(env->GetStringUTFChars(s, NULL)) 
  { 
  } 

  ~utf_chars() 
  { 
    env_->ReleaseStringUTFChars(s_, c_); 
  } 

  const char *get() 
  { 
    return c_; 
  } 

private: 
  JNIEnv *env_; 
  jstring s_; 
  const char *c_; 
}; 

JNIEXPORT void JNICALL Java_HelloWorld_print(JNIEnv *env, jclass cl, jstring s) 
{ 
  utf_chars utf(env, s); 
  MessageBox(NULL, utf.get(), "JNI Message", MB_OK); 
} 
