E
Elena
Hello,
I've developed a native application which loads a Java class at
runtime via JNI. Required JRE is 1.6 or newer.
Since availability of JRE should be optional, I'm looking for jvm.dll
at runtime. I'm not sure about how to properly find its path.
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
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)) ;
It works, but is it the proper way?
Thanks.
I've developed a native application which loads a Java class at
runtime via JNI. Required JRE is 1.6 or newer.
Since availability of JRE should be optional, I'm looking for jvm.dll
at runtime. I'm not sure about how to properly find its path.
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
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)) ;
It works, but is it the proper way?
Thanks.