Hi,
Has anyone tried creating multiple JVMs in a single process? I am using jdk 1.4. and using C++ native methods to invoke the JVM.
To
test, I tried 2 successive calls to
jint ret1 = JNI_CreateJavaVM(&_jvm1, (void **)&localJNIEnv1, &javaVMArgs);
jint ret2 = JNI_CreateJavaVM(&_jvm2, (void **)&localJNIEnv2, &javaVMArgs);
javaVMArgs is initialized correctly. ret1 = 0 indicating success. ret2 = -1 (JNI_ERR in jni.h, which is an unknown error). If there is a limitiation to create more than one JVM, then I'd have expected error returned to be -5 (JNI_EEXIST which means VM already created).
Java Invocation API
doc http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/invocation.html mentions that "JDK 1.1.2 does not support creating more than one VM in a single process." in one place and "JDK 1.1 does not support creating more than one VM in a single process. " in another place. No mention of jdk 1.4 however.
If anyone has tried this successfully or has any ideas, I'd appreciate feedback. Thanks.