How to Use the Foreign Function API in Java 22 to Call C Libraries

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Sevalla - Deploy and host your apps and databases, now with $50 credit!
Sevalla is the PaaS you have been looking for! Advanced deployment pipelines, usage-based pricing, preview apps, templates, human support by developers, and much more!
sevalla.com
featured
InfluxDB – Built for High-Performance Time Series Workloads
InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.
www.influxdata.com
featured
  1. JNA

    Java Native Access

    According to JNA it's not safe to unload the DLL:

    https://github.com/java-native-access/jna/blob/40f0a1249b5ad...

    > Do NOT force the class loader to unload the native library, since

  2. Sevalla

    Deploy and host your apps and databases, now with $50 credit! Sevalla is the PaaS you have been looking for! Advanced deployment pipelines, usage-based pricing, preview apps, templates, human support by developers, and much more!

    Sevalla logo
  3. jextract

    https://openjdk.org/projects/code-tools

    I don't think so, given that there are more popular Java libraries than popular libraries with a C ABI. There is a small number of very popular C libraries that result in the majority of native call uses. But in any event, calling native libraries in Java is now no longer a pain thanks to FFM (and jextract [1]) so we'll see.

    Note that interaction with native libraries often requires more careful management of native memory that -- even though it's much easier now with FFM -- is still significantly trickier (and more dangerous in terms of introducing undefined behaviour) than interacting with Java code regardless of how that interaction is declared. In Java, as in Python, interaction with native code -- in the vast majority of cases -- is best encapsulated inside a Java library and not often directly exposed to application programmers.

    [1]: https://github.com/openjdk/jextract

  4. Silk.NET

    The high-speed OpenGL, OpenCL, OpenAL, OpenXR, GLFW, SDL, Vulkan, Assimp, WebGPU, and DirectX bindings library your mother warned you about.

    Genuine curiosity - what would be your motivation to use Java over C# here aside from familiarity (which is perfectly understandable)? The latter takes heavy focus on making sure to provide features like structs and pointers with little to no friction, you can even AOT compile it and statically link SDL2 into a single executable.

    But either way, if you want to try it out, then all it needs is

    - SDK from https://dot.net/download (or package manager of your choice if you are on Linux e.g. `sudo apt-get install dotnet-sdk-8.0`, !do not! use Homebrew if you are on macOS however, use .pkg installer)

    - C# extension for VS Code (DevKit is not needed)

    - SDL2 bindings: https://github.com/dotnet/Silk.NET

  5. gir.core

    A C# binding generator for GObject based libraries providing a C# friendly API surface

    FreeBSD: `pkg install lang/dotnet` (from https://www.freshports.org/lang/dotnet)

    GObject (GTK4 and similar): https://github.com/gircore/gir.core (significantly better and faster than Java alternatives, this is just one example among many)

    Young: first OSS version was released 8 years ago

    Solaris: might as well say "it runs COBOL but not .NET"

    It's funny that everyone missed the initial context of the question and jumped onto parroting the same arguments as years ago, without actually addressing the matter at hand or saying anything of substance. Unsurprising show of ignorance by Java community. Please stay this way - will help the industry to move on faster.

    The premise is always the same - if something is missing in {technology I don't like}, it's a deal-breaker, and when it's not or was always there - it never mattered, or is harmful actually, that is, until {technology I like} gets it as well.

  6. libGDX

    Desktop/Android/HTML5/iOS Java game development framework

  7. luajava

    Lua for Java on Windows, Mac OS X, Linux, Android. 5.1, 5.2, 5.3, 5.4, LuaJ or LuaJIT. (by gudzpoz)

  8. .NET Runtime

    .NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.

    Async/await is not a tight corner as showcased by a multitude of languages adopting the pattern: Rust, Python, JavaScript and Swift.

    In fact, it is a clean abstraction where future progress is possible while retaining the convenience of its concurrency syntax and task composition.

    Green threads experiment proved net negative in terms of benefit but its the follow-up work on modernizing the implementation detail was very successful: https://github.com/dotnet/runtime/issues/94620 / https://github.com/dotnet/runtimelab/blob/feature/async2-exp...

    It also seems that common practices in Java indicate that properties are not a mistake as showcased by popularity of Lombok and dozens of other libraries to generate builders and property-like methods (or, worse, Java developers having to write them by hand).

  9. InfluxDB

    InfluxDB – Built for High-Performance Time Series Workloads. InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.

    InfluxDB logo
  10. runtimelab

    This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo.

    Async/await is not a tight corner as showcased by a multitude of languages adopting the pattern: Rust, Python, JavaScript and Swift.

    In fact, it is a clean abstraction where future progress is possible while retaining the convenience of its concurrency syntax and task composition.

    Green threads experiment proved net negative in terms of benefit but its the follow-up work on modernizing the implementation detail was very successful: https://github.com/dotnet/runtime/issues/94620 / https://github.com/dotnet/runtimelab/blob/feature/async2-exp...

    It also seems that common practices in Java indicate that properties are not a mistake as showcased by popularity of Lombok and dozens of other libraries to generate builders and property-like methods (or, worse, Java developers having to write them by hand).

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Compiling Java into Native Binaries with Graal and Mill

    4 projects | news.ycombinator.com | 1 Feb 2025
  • Finally Contributing Actual Code to Open Source

    2 projects | dev.to | 13 Oct 2024
  • Ubisoft-backed Blockchain RPG Lets Players ‘Fork’ the Game - Decrypt

    1 project | /r/Games | 30 Dec 2020
  • planetarium/libplanet: .NET Library for Serverless Multiplayer Game

    1 project | /r/gamedev | 27 Dec 2020
  • The Daily Gist: Never miss the best of Reddit again. Powered by Bright Data.

    2 projects | dev.to | 31 Aug 2025

Did you know that Java is
the 8th most popular programming language
based on number of references?