#include "Date.h" #include using namespace std; JNIEXPORT void JNICALL Java_Date_printDate(JNIEnv * env, jobject ths) { jint m, d, y; jclass cls = env->GetObjectClass( ths ); jmethodID id_toString = env->GetMethodID( cls, "toString", "()Ljava/lang/String;" ); jstring str = (jstring) env->CallObjectMethod( ths, id_toString ); const char *c_ret = env->GetStringUTFChars( str, NULL ); cout << "(calling toString) " << c_ret << endl; env->ReleaseStringUTFChars( str, c_ret ); }