I'm porting our native windows app launcher from Java 8 to Java 11. We used to call JNI_CreateJavaVM
method to instantiate a JVM instance, find main class and call its main
method. With a modular app, env->FindClass
doesn't return our app class. I tried calling Class.forName
and it doesn't return a class instance as well.
Also, JNI_CreateJavaVM
complaints about --add-modules
argument.
How should we specify modules to load for the JNI api?
What can I do to find the app class from the native part?
I was able to run a Java app using JLI api instead. I used this code to invoke JLI api: https://github.com/MovingBlocks/TerasologyJavaLauncher/blob/master/jli_library_win.cpp
It seems that a hack with app hooks isn't necessary anymore. I tried with JDK 11.0.2 and it worked correctly "as-is" without hacking jli.dll path.