0

我有以下代码。在 LINUX 中编译这段代码的命令是什么。gcc ThisFile.C 说 JNI_VERSION_1_6 未声明..

#include <stdio.h>
#include <jni.h>
#include <string.h>

JNIEnv* create_vm(JavaVM ** jvm) {

    JNIEnv *env;
    JavaVMInitArgs vm_args;
    JavaVMOption options;

    vm_args.version = JNI_VERSION_1_6; //JDK version. This indicates version 1.6
    vm_args.nOptions = 1;
    vm_args.options = &options;
    vm_args.ignoreUnrecognized = 0;

    int ret = JNI_CreateJavaVM(jvm, (void**)&env, &vm_args);
    if(ret < 0)
        printf("\nUnable to Launch JVM\n");
    return env;
}


int main(int argc, char* argv[])
{
    JNIEnv *env;
    JavaVM * jvm;

    return 1;
}
4

1 回答 1

1

好的,我自己回答了。希望这会对某人有所帮助

echo $JAVA_HOME /usr/lib/jvm/java-1.6.0 gcc -o 调用 -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux -L$JAVA_HOME/jre/lib/amd64/server/ -ljvm 调用。C

于 2013-05-21T22:01:06.753 回答