5

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?

Ivan Nikitin
  • 3,578
  • 27
  • 39
  • I published an answer to this in this Stackoverflow question: https://stackoverflow.com/questions/49781048/module-path-in-c-to-java-jni-call – Loïc Decloedt Dec 05 '22 at 07:57

1 Answers1

2

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.

Ivan Nikitin
  • 3,578
  • 27
  • 39