By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,034 Members | 822 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,034 IT Pros & Developers. It's quick & easy.

Problems with JNI Invocation Interface

P: n/a
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.
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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" <dl*****@gte.net> wrote in message
news:8O****************@nwrddc03.gnilink.net...
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.

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.