I understand that this is a question that several people have already asked, but their answers did not fix my problem.
I'm currently trying to create a QT application, and I have some code written in Java that I would like to use, so I decided to implement JNI in my application.
I use the following code to initialize a virtual machine:
JNIEnv* SokoSolver::createVM(JavaVM **JVM){
JNIEnv* Env;
JavaVMInitArgs args;
JavaVMOption options;
options.optionString = "-Djava.class.path=./";
args.version = JNI_VERSION_1_6;
args.nOptions = 1;
args.options = &options;
args.ignoreUnrecognized = 0;
int returnValue = JNI_CreateJavaVM(JVM, (void**)&Env, &args);
if(returnValue < 0 || !Env){
cout << "Unable to launch JVM, Return Value: " << returnValue << endl;
}
return Env;
}
However, whenever my code runs, an error message appears:
An error occurred while initializing the virtual machine. Failed to load own library: unable to find dependent libraries.
I am using the x86 version of JVM.lib / JVM.dll, as well as the corresponding header files. According to other answers, I changed the path variable in Windows to start with:
C:\Program Files (x86)\Java\jdk1.8.0_74\bin;
C:\Program Files (x86)\Java\jdk1.8.0_74\jre\bin\server;
, . ? - :
options.optionString = "-Djava.class.path=./";