This is similar to How to call a C function from Java 17 using JEP 412: Foreign Function & Memory API
but the API has changed in the move from JDK 17 -> 18.
Asking the question again: Does anybody have a simple example on how to call a C function from Java 18? I'm stuck trying to translate the accepted answer in the Java 17 question.
from this mailing list message: https://mail.openjdk.java.net/pipermail/panama-dev/2022-April/016764.html
i found this link: https://github.com/openjdk/panama-foreign/blob/foreign-jextract/doc/panama_ffi.md
which includes this example:
run as:
java --add-modules jdk.incubator.foreign --enable-native-access=ALL-UNNAMED Examples.java