79127919

Date: 2024-10-26 06:10:50
Score: 0.5
Natty:
Report link

I find another solution. Just rm jvm.dll in workspace, then


typedef int (__stdcall * JNI_CreateJavaVMFunc)(JavaVM** pvm, JNIEnv** penv, void* args);

HINSTANCE jvmDLL = LoadLibraryA("C:\\Program Files\\Zulu\\zulu-17\\bin\\server\\jvm.dll");

JNI_CreateJavaVMFunc Dll_JNI_CreateJavaVM = (JNI_CreateJavaVMFunc)GetProcAddress(jvmDLL, "JNI_CreateJavaVM");
JavaVM* jvm = nullptr;
JNIEnv* env = nullptr;
JavaVMInitArgs vm_args; /* JDK/JRE 19 VM initialization arguments */
JavaVMOption* options = new JavaVMOption[1];
char arg[50] = "-verbose:jni";
options[0].optionString = arg;
vm_args.version = JNI_VERSION_1_8;
vm_args.nOptions = 1;
vm_args.options = options;
vm_args.ignoreUnrecognized = true;

auto check = Dll_JNI_CreateJavaVM(&jvm, & env, &vm_args);

Then everything works fine...

Do not use JNI_CreateJavaVM in jni.h

I found this solution from jni-sys

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: kouhe3