JavaVM *javaVM = NULL; JNIEnv *jniEnv = NULL;
( createJavaVM )( &javaVM, ( void * )&jniEnv, &javaVMInitArgs )
where javaVM * and jniEnv * are global variables
JavaVM *javaVM = NULL; JNIEnv *jniEnv = NULL;
( createJavaVM )( &javaVM, ( void * )&jniEnv, &javaVMInitArgs )
where javaVM * and jniEnv * are global variables
Is it ok to save JavaVM * as a global variable and use it elsewhere?
Yes.
Is it ok to save JNIEnv * as a global variable and use it elsewhere?
No. That represents a context for a specific JNI method invocation. It is dependent on the current thread, the arguments to the current method, the local references that have been created by the current method, all sorts of things, and it becomes invalid once that JNI method returns.