JNI_GetCreatedJavaVMs problem (explicit or implicit link)
Hi,
I have a Java class calls C calls others java class ...
in C , i need to use JNI_GetCreatedJavaVMs with a LoadLibrary.
(Visual Studio 2005, JDK 1.6, JRE 1.6)
static JavaVM *FindCreatedJavaVM(void)
{
JavaVM *jvm = NULL;
jsize jvm_count = 0;
jint res=0;
#ifdef __STATIC_LIB_JVM
res = JNI_GetCreatedJavaVMs (&jvm, 1, &jvm_count);
#else
{
HINSTANCE hLibJVM;
typedef jint (JNICALL GetCreatedJavaVMs_t)( JavaVM**, jsize, jsize* );
GetCreatedJavaVMs_t *MyGetCreatedJavaVMs;
hLibJVM = LoadLibrary("e:/jre/bin/client/jvm.dll");
MyGetCreatedJavaVMs = (GetCreatedJavaVMs_t*)GetProcAddress( hLibJVM, "JNI_GetCreatedJavaVMs" );
res = MyGetCreatedJavaVMs(&jvm, 1, &jvm_count);
}
#endif
if (res == 0)
{
if ( jvm_count == 0 )
{
jvm = NULL;
}
}
else jvm = NULL;
return jvm;
}
/*--*/
if i use a implicit link of jvm.dll (#define __STATIC_LIB_JVM)
this example works. i find a jvm
if i use a explicit link of jvm.dll, i don't find a jvm.
hLibJVM & MyGetCreatedJavaVMs != NULL (path for jvm.dll is ok)
Where is the problem ?
Thanks you for your help
Allan

