javajava-native-interfaceproject-panama

Calling a Java function from C using Foreign Function & Memory API


All examples I've come across for calling a Java method from C using the Foreign Function & Memory API involve callbacks, that is, a Java method that runs some native function with a Java callback as a parameter.

What about C calling a Java method directly? Is JNI still the only way to do that?


Solution

  • Yes, as far as I know JNI is still the only option to call a Java method from C. There are no alternatives currently in Project Panama for calling Java from native C.