Problems with JNI Invocation Interface

D

Dr. Dave Landis

Greetings:

I have a group of Java classes that I need to invoke from a Win32 DLL. The
following code, when executed from a stand-alone EXE works just fine. When
I insert it into my DLL, the JNI_CreateJavaVM function hangs. I'm not even
getting around to calling my classes, just trying to start the VM. The
jvm.dll is in my path. I've tried linking various MS runtimes, all to the
same effect -- the call to JNI_CreateJavaVM hangs permanently ( as a side
note, when this function is called, hpi.sll, verify.dll, java.dll and
zip.dll all get loaded, then the hang occurs). Please help. I'm in a
desparate time crunch.

Dave

<< code >>
BOOL InitJavaDriver(char* classname)
{
JNIEnv* env;
JavaVM* jvm;
jint retval;
char opt0[400];
char opt1[400];
int i;

JavaVMInitArgs vm_args;
JavaVMOption options[2];

memset(options,0,2*sizeof(JavaVMOption));
sprintf(opt0,"-Djava.class.path=%s\\OOIDrvJ.jar",BasePath);
sprintf(opt1,"-Djava.library.path=%s",BasePath);
options[0].optionString=opt0;
options[1].optionString=opt1;
vm_args.version=JNI_VERSION_1_2;
vm_args.options=options;
vm_args.nOptions=2;
vm_args.ignoreUnrecognized=JNI_TRUE;

retval=JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args); ////// this is the
line that kills it
return TRUE;
}

<< debug output >>
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information
found.
Loaded symbols for 'D:\OOIProg\Working\OOIDrv\OOIDrv32.dll' <<<<<<< my dll
Loaded symbols for 'C:\WINDOWS\system32\MSVCRTD.DLL'
Loaded 'C:\WINDOWS\system32\winmm.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\user32.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\gdi32.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\version.dll', no matching symbolic information
found.
Loaded 'C:\Program Files\Java\j2re1.4.1_03\bin\client\jvm.dll', no matching
symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\imm32.dll', no matching symbolic information
found.

<<<<< this starts my dll, the stuff below is loaded when i try to create the
VM

Loaded 'C:\Program Files\Java\j2re1.4.1_03\bin\hpi.dll', no matching
symbolic information found.
Loaded 'C:\Program Files\Java\j2re1.4.1_03\bin\verify.dll', no matching
symbolic information found.
Loaded 'C:\Program Files\Java\j2re1.4.1_03\bin\java.dll', no matching
symbolic information found.
Loaded 'C:\Program Files\Java\j2re1.4.1_03\bin\zip.dll', no matching
symbolic information found.
 
D

Dr. Dave Landis

Nevermind. It turns out that you can call JNI_CreateJavaVM from the DllMain
of a DLL. No clue why, but if I move the call out of DllMain, it all works.

Dr. Dave Landis said:
Greetings:

I have a group of Java classes that I need to invoke from a Win32 DLL. The
following code, when executed from a stand-alone EXE works just fine. When
I insert it into my DLL, the JNI_CreateJavaVM function hangs. I'm not even
getting around to calling my classes, just trying to start the VM. The
jvm.dll is in my path. I've tried linking various MS runtimes, all to the
same effect -- the call to JNI_CreateJavaVM hangs permanently ( as a side
note, when this function is called, hpi.sll, verify.dll, java.dll and
zip.dll all get loaded, then the hang occurs). Please help. I'm in a
desparate time crunch.

Dave

<< code >>
BOOL InitJavaDriver(char* classname)
{
JNIEnv* env;
JavaVM* jvm;
jint retval;
char opt0[400];
char opt1[400];
int i;

JavaVMInitArgs vm_args;
JavaVMOption options[2];

memset(options,0,2*sizeof(JavaVMOption));
sprintf(opt0,"-Djava.class.path=%s\\OOIDrvJ.jar",BasePath);
sprintf(opt1,"-Djava.library.path=%s",BasePath);
options[0].optionString=opt0;
options[1].optionString=opt1;
vm_args.version=JNI_VERSION_1_2;
vm_args.options=options;
vm_args.nOptions=2;
vm_args.ignoreUnrecognized=JNI_TRUE;

retval=JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args); ////// this is the
line that kills it
return TRUE;
}

<< debug output >>
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information
found.
Loaded symbols for 'D:\OOIProg\Working\OOIDrv\OOIDrv32.dll' <<<<<<< my dll
Loaded symbols for 'C:\WINDOWS\system32\MSVCRTD.DLL'
Loaded 'C:\WINDOWS\system32\winmm.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\user32.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\gdi32.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\version.dll', no matching symbolic information
found.
Loaded 'C:\Program Files\Java\j2re1.4.1_03\bin\client\jvm.dll', no matching
symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information
found.
Loaded 'C:\WINDOWS\system32\imm32.dll', no matching symbolic information
found.

<<<<< this starts my dll, the stuff below is loaded when i try to create the
VM

Loaded 'C:\Program Files\Java\j2re1.4.1_03\bin\hpi.dll', no matching
symbolic information found.
Loaded 'C:\Program Files\Java\j2re1.4.1_03\bin\verify.dll', no matching
symbolic information found.
Loaded 'C:\Program Files\Java\j2re1.4.1_03\bin\java.dll', no matching
symbolic information found.
Loaded 'C:\Program Files\Java\j2re1.4.1_03\bin\zip.dll', no matching
symbolic information found.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top