Re: Correct way to load jvm.dll in a JNI application?
- From: jolz <BardzoTajneKonto@xxxxxxxxxx>
- Date: Thu, 23 Jul 2009 23:34:51 +0200
Currently I'm querying the Windows registry like this:
- read value at HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime
Environment\CurrentVersion;
- read value HKEY_LOCAL_MACHINE\SOFTWARE\\JavaSoft\\Java Runtime
Environment\<CurrentVersion>\RuntimeLib
I don't think java is required to put anything in the registry. Also there may be installed JDK without JRE and the key in registry may be different (it is different with Sun's JVM). The may be also several different JVMs in the registry.
Trying to guess correct JVM location is a good idea but you should consider to let end user configure the location.
Then I put jvm.dll's folder in front of process' PATH environment
variable and then execute:
JavaVM *vm=NULL;
JNIEnv* java_env=NULL;
JavaVMInitArgs vm_args={0};
vm_args.version = JNI_VERSION_1_6;
JNI_GetDefaultJavaVMInitArgs(&vm_args);
// assignment of vm_args.options skipped...
JNI_CreateJavaVM(&vm, (void **)&java_env, &vm_args)) ;
Try loading java library dynamically (on windows start with LoadLibrary() function) - this way you won't have to link your application with jvm.lib and in case of any error you can handle it in the application (default windows behaviour is to show message box and stop loading application).
.
- Follow-Ups:
- References:
- Prev by Date: Re: Change Clip using reflaction
- Next by Date: Conditional Regular Expressions in ORO
- Previous by thread: Re: Correct way to load jvm.dll in a JNI application?
- Next by thread: Re: Correct way to load jvm.dll in a JNI application?
- Index(es):
Relevant Pages
|