#"Failed setting boot class path." when creating java vm with JNI with Java 21

1 messages · Page 1 of 1 (latest)

mighty ivy
#

when I try creating a java vm with jni, no matter what I change it just crashes with this message in the console:

Error occurred during initialization of VM
Failed setting boot class path.
    std::string optionString = "-Djava.class.path=.";
    for (char& c : optionString)
    {
        if (c == '\\')
            c = '/';
    }

    JavaVMOption option{};
    option.optionString = optionString.data();

    JavaVMInitArgs vm_args;
    vm_args.version = JNI_VERSION_1_8; //tried setting to 1.8 to check if that helps with anything
    vm_args.nOptions = 1;
    vm_args.options = &option;
    vm_args.ignoreUnrecognized = JNI_TRUE;

    JavaVM* pJavaVM = nullptr;
    JNIEnv* pEnv = nullptr;
    JNI_CreateJavaVM(&pJavaVM, rcast<void**>(&pEnv), &vm_args);

and I have put all dlls from java's bin directory next to my exe

sullen burrowBOT
#

<@&987246683568103514> please have a look, thanks.

mighty ivy
#

so I fixed the issue by add %JAVA_HOME%/bin/server to %PATH%