sureshnarsimhan
March 7th, 2002, 03:03 AM
Hi,
I encountered a problem when trying to load a java class from a c++.
I have two DLLs say A and B, each of which loads the java VM to execute a java function. (Each dll loads up a different java class to execute its function).
I have an EXE from which I am trying to load both the DLLS, A first and B second (to invoke appropriate java function)
The EXE Loads up DLL A first, the A DLL successfully loads the JAVA VM and makes the call to appropriate function.
When I am trying to do the same the second time from B, the call
ifn.JNI_CreateJavaVM(&m_virtualMachine, &m_environment, &m_virtualMachineArguments);
returns a negative value in the second DLL B.( Loading the VM from the first DLL works fine, when I try to the same for a second time from DLL B it fails)
I have destroyed the java VM by calling
m_virtualMachine->DestroyJavaVM();
in both the dlls.
I tried calling
JNI_GetCreatedJavaVMs(&m_virtualMachine,(jsize)1,&nVMs);
AttachCurrentThread((void **)&m_environment,thr_args);
In the Dll B.
This constructs the VM but fails in the findClass method( FindClass( class_name ); returns null value;)
What should i do load the java VM twice from two seperate Dlls??
Thanks in advance,
Suresh.n
I encountered a problem when trying to load a java class from a c++.
I have two DLLs say A and B, each of which loads the java VM to execute a java function. (Each dll loads up a different java class to execute its function).
I have an EXE from which I am trying to load both the DLLS, A first and B second (to invoke appropriate java function)
The EXE Loads up DLL A first, the A DLL successfully loads the JAVA VM and makes the call to appropriate function.
When I am trying to do the same the second time from B, the call
ifn.JNI_CreateJavaVM(&m_virtualMachine, &m_environment, &m_virtualMachineArguments);
returns a negative value in the second DLL B.( Loading the VM from the first DLL works fine, when I try to the same for a second time from DLL B it fails)
I have destroyed the java VM by calling
m_virtualMachine->DestroyJavaVM();
in both the dlls.
I tried calling
JNI_GetCreatedJavaVMs(&m_virtualMachine,(jsize)1,&nVMs);
AttachCurrentThread((void **)&m_environment,thr_args);
In the Dll B.
This constructs the VM but fails in the findClass method( FindClass( class_name ); returns null value;)
What should i do load the java VM twice from two seperate Dlls??
Thanks in advance,
Suresh.n