#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_getMonth = env->GetMethodID( cls, "getMonth", "()I" ); jmethodID id_getDay = env->GetMethodID( cls, "getDay", "()I" ); jmethodID id_getYear = env->GetMethodID( cls, "getYear", "()I" ); m = env->CallIntMethod( ths, id_getMonth ); d = env->CallIntMethod( ths, id_getDay ); y = env->CallIntMethod( ths, id_getYear ); std::cout << m << " " << d << ", " << y << endl; }