Does Java 18 finally have a better alternative to JNI?

This page summarizes the projects mentioned and recommended in the original post on dev.to

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • JNA

    Java Native Access

    The complexity of JNI has given rise to some community-driven libraries that make it simpler to do FFI in Java. Java Native Access (JNA) is one of them. It's built on top of JNI and at least makes FFI easier to use, especially as it removes the need to write any C binding code manually and reduces the chances of memory safety issues. Still, it has some of the disadvantages of being JNI-based and is slightly slower than JNI in many cases. However, JNA is widely used and battle-tested, so definitely a better option than using JNI directly.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • JNR

    Java Abstracted Foreign Function Layer

    Another popular option is Java Native Runtime (JNR). Though not as widely used or mature as JNA, it's much more modern and has better performance than JNA for most use cases. However, there are some cases where JNA might perform better.

  • jmh

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

    Let's run some Java Microbenchmark Harness (JMH) benchmarks to compare the performance of JNI and Panama API. We will use the getpid function from the standard C unistd header for the comparison. We will call the API using JNI and Panama APIs and compare the performance. I'm running the benchmark on Linux with OpenJDK 19 early access build for Panama (openjdk 19-panama 2022-09-20).

  • JavaCPP

    The missing bridge between Java and native C++

    Here is the code for JNI, which uses the prebuilt JavaCPP library to call the getpid function. We don't have to write all the manual C binding code and rituals as the JavaCPP library already does it.

  • Java-FFI-benchmarks

    Benchmarks for Java JNI vs Project Panama on Linux with JDK 17

    If you would like to run the benchmarks yourself, follow the instructions in the readme file on the source repository

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
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

  • How can I use K/N with C++?

    2 projects | /r/Kotlin | 27 Aug 2022
  • JEP 419: Foreign Function and Memory API

    4 projects | news.ycombinator.com | 29 Mar 2022
  • An article on how to use C++ for cross-platform development

    1 project | /r/cpp | 11 Mar 2021
  • How to quickly learn/understand the system architecture of any given application?

    1 project | /r/devops | 7 Mar 2023
  • Tools/software for visualizing code structure/dependencies of large C project.

    2 projects | /r/embedded | 3 Jan 2023

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