Calling Java from C++ Frame not in module
C / C++ / MFC
1
Posts
1
Posters
3
Views
1
Watching
-
I read this tutorial about how you can use Java inside your C++ project and I wanted to do some testing with it, but without changing anything in the project (only the path to /include and /win32 to my specific system) I'm getting the following exception: [^] [^] There are no errors in the project. Running a debug the error occurs at this line:
jint rc = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
Source:
// Example 2 of JNI invocation.
// The java environment is prepared. Errors are reported.
// Call to a simple static java methods
// License: ZLIB license (see license.txt)
// (c) Copyright 2015 by cth027#include #include int main()
{
using namespace std;JavaVM \*jvm; // Pointer to the JVM (Java Virtual Machine) JNIEnv \*env; // Pointer to native interface //==================== prepare loading of Java VM ============================ JavaVMInitArgs vm\_args; // Initialization arguments JavaVMOption\* options = new JavaVMOption\[1\]; // JVM invocation options options\[0\].optionString = "-Djava.class.path=."; // where to find java .class vm\_args.version = JNI\_VERSION\_1\_6; // minimum Java version vm\_args.nOptions = 1; // number of options vm\_args.options = options; vm\_args.ignoreUnrecognized = false; // invalid options make the JVM init fail //================= load and initialize Java VM and JNI interface =============== jint rc = JNI\_CreateJavaVM(&jvm, (void\*\*)&env, &vm\_args); // YES !! delete\[\] options; // we then no longer need the initialisation options. //========================= analyse errors if any ============================== // if process interuped before error is returned, it's because jvm.dll can't be // found, i.e. its directory is not in the PATH. if(rc != JNI\_OK) { if(rc == JNI\_EVERSION) cerr << "FATAL ERROR: JVM is oudated and doesn't meet requirements" << endl; else if(rc == JNI\_ENOMEM) cerr << "FATAL ERROR: not enough memory for JVM" << endl; else if(rc == JNI\_EINVAL) cerr << "FATAL ERROR: invalid ragument for launching JVM" << endl; else if(rc == JNI\_EEXIST)