我正在尝试为我的 Java 服务器编写 Windows 服务。这是我编写invokeshutdown
方法的方式。但我对如何jobject
在这里获得参考感到困惑。
DWORD WINAPI InvokeShutdown( LPVOID lpParam ) {
JNIEnv *env;
jclass cls;
jmethodID mid;
//Since the JVM was created in a another thread. We have to attach the thread
//to JVM before making " calls
vm->AttachCurrentThread((void **)&env, 0);
cls = env->FindClass("com.my.internal.Launcher");
// Create the argument list.
va_list args;
va_start(args, "-dir=stop");
mid = env->GetMethodID(env, cls, "stop", "()V");
env->CallVoidMethodV(env, obj, mid, args);
vm->DetachCurrentThread();
Log( "Detached thread\n");
return 0;
}
我怎么obj
进去env->CallVoidMethodV(env, obj, mid, args);