The Foreign Function and Memory API
These tutorials help with understanding the Foreign Function and Memory (FFM) API capabilities to invoke code outside the JVM (foreign functions) and to safely access memory not managed by the JVM (foreign memory). The FFM API facilitates Java applications to call native libraries and process native data without the brittleness and danger of JNI.
-
Access Off-Heap or On-Heap Memory with Memory Segments
Learn how to access off-heap or on-heap memory with the Foreign Function and Memory (FFM) API through MemorySegment and Arenas.
-
Invoke a C Library Function
Find out how to call a C library function from Java.
-
Access Native Data Types
Discover how to access a C structure with MemoryLayout and further slice memory segments.
-
How to Handle a Call from Native Code Back to Java Code
Pass Java code as a function pointer to a foreign function.
-
Troubleshoot Calls to Native Library Functions
Invoke foreign functions that return pointers and check for potential errors.
-
Generate Java Bindings with Jextract
Run jextract and use the generated Java bindings to integrate native libraries in your application.