Skip Top Navigation Bar

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.


  1. 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.

  2. Invoke a C Library Function

    Find out how to call a C library function from Java.

  3. Access Native Data Types

    Discover how to access a C structure with MemoryLayout and further slice memory segments.

  4. How to Handle a Call from Native Code Back to Java Code

    Pass Java code as a function pointer to a foreign function.

  5. Troubleshoot Calls to Native Library Functions

    Invoke foreign functions that return pointers and check for potential errors.

  6. Generate Java Bindings with Jextract

    Run jextract and use the generated Java bindings to integrate native libraries in your application.



More Learning



Back to Tutorial List