1 #include "jni.h" 2 #include "stdio.h" 3 #include "stdlib.h" 4 5 int main(int argc, char** args) { 6 JavaVMInitArgs vm_args; 7 JNIEnv *env; 8 JavaVM *vm; 9 int i =0; 10 jint result; 11 12 vm_args.version = JNI_VERSION_1_2; 13 vm_args.ignoreUnrecognized = JNI_FALSE; 14 15 JavaVMOption option1[2]; 16 option1[0].optionString="-XX:+PrintCommandLineFlags"; 17 option1[1].optionString="-Xrs"; 18 19 vm_args.options=option1; 20 vm_args.nOptions=2; 21 22 // Print the VM options in use 23 printf("initVM: numOptions = %d\n", vm_args.nOptions); 24 for (i = 0; i < vm_args.nOptions; i++) 25 { 26 printf("\tvm_args.options[%d].optionString = %s\n", i, vm_args.options[i].optionString); 27 } 28 29 // Initialize VM with given options 30 result = JNI_CreateJavaVM( &vm, (void **) &env, &vm_args ); 31 if (result != 0) { 32 printf("ERROR: cannot create JAVA VM.\n"); 33 exit(-1); 34 } 35 36 (*vm)->DestroyJavaVM(vm); 37 } 38