JNIEnv* create_vm(JavaVM** jvm) { JNIEnv* env; JavaVMInitArgs vm_args; JavaVMOption options; options.optionString = "-Djava.class.path=*"; vm_args.version = JNI_VERSION_1_8; vm_args.nOptions = 1; vm_args.options = &options; vm_args.ignoreUnrecognized = 0; int res = JNI_CreateJavaVM(jvm, (void**)&env, &vm_args); if (res < 0) { printf("Error code:%d\n", res); } return env; } int main() { JNIEnv* env; JavaVM* jvm; env = create_vm(&jvm); if (env == NULL) { printf("Failed to get env"); return 1; } jclass cls = (*env)->FindClass(env, "*"); if (cls != NULL) { printf("Found the class"); jmethodID jmid = (*env)->GetStaticMethodID(env, cls, "main", "([Ljava/lang/String;)V"); if (jmid != NULL) { (*env)->CallStaticVoidMethod(env, cls, jmid, NULL); //Here printf("env->CallStaticVoidMethod returned\n"); } } else { printf("\nUnable to find the requested class\n"); } return 0; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)