I\'m trying to call / execute a java jar from a C++ program.
Here are the options I\'ve found so far:
I had a similar issue and realized the problem was that I was compiling, in Ubuntu, with a version of JDK that was meant for Windows and not Linux. It worked when I compiled in Cygwin instead. Alternatively, if I wanted to keep using Ubunutu, I could have tried a JDK for Linux instead.
Usually you have to add some kind of platform specific directory as well like on Linux:
g++ -I /usr/lib/jvm/jdk1.6.0_34-x86/include/ -I /usr/lib/jvm/jdk1.6.0_34-x86/include/linux Hello.cpp
because a few macros (like JNICALL
) are set up there. Hopefully that'll fix the jni.h error cascade.
EDIT: Still stuck? Try:
JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
It'll at least get past the compilation problem. I don't know if it'll work, since I've not tried this before.