Using JNI to execute a java jar from a C++ program, using g++ or eclipse

后端 未结 2 1916
孤街浪徒
孤街浪徒 2020-12-10 20:58

I\'m trying to call / execute a java jar from a C++ program.

Here are the options I\'ve found so far:



        
2条回答
  •  渐次进展
    2020-12-10 21:54

    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.

提交回复
热议问题