'JNI: Can't find dependent libraries
I get this error when I run my program with JNI
Error occurred during initialization of VM
Unable to load native library: Can't find dependent libraries
I moved all JDK 8 DLL files to the working directory but it didn't help.
I also tried setting JAVA_HOME to the JRE path but that didn't help.
I also tried Dependency Walker, it says there are some DLLs not found that JDK 8 doesn't have
My JVM creation code:
JVM create_java_vm()
{
const char* argv[] = { "-Djava.compiler=NONE,
"-Djava.class.path=.",}; //"-verbose:jni"
const int argc = static_cast<int>(sizeof(argv) / sizeof(argv[0]));
JavaVMInitArgs jvm_args;
JavaVMOption options[argc];
for (int i = 0; i < argc; ++i)
{
options[i].optionString = const_cast<char*>(argv[i]);
}
JavaVM* vm = nullptr;
JNIEnv* env = nullptr;
JNI_GetDefaultJavaVMInitArgs(&jvm_args);
jvm_args.version = JNI_VERSION_1_8;
jvm_args.nOptions = argc;
jvm_args.options = options;
jvm_args.ignoreUnrecognized = false;
if (JNI_CreateJavaVM(&vm, reinterpret_cast<void**>(&env), &jvm_args) != JNI_OK)
{
return { vm, env }
}
return { vm, env }
}
I also tried this but the program couldn't find jvm.dll
How do I solve this error?
Solution 1:[1]
i solved this problem adding my exe file to server folder in jre
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | nonxis |