JavaCPP VS JNA

Compare JavaCPP vs JNA and see what are their differences.

JavaCPP

The missing bridge between Java and native C++ (by bytedeco)

JNA

Java Native Access (by java-native-access)
Our great sponsors
  • Scout APM - Less time debugging, more time building
  • SonarLint - Deliver Cleaner and Safer Code - Right in Your IDE of Choice!
  • SaaSHub - Software Alternatives and Reviews
JavaCPP JNA
5 18
3,826 7,128
0.9% 1.1%
7.6 7.7
about 1 month ago 7 days ago
Java Java
GNU General Public License v3.0 or later GNU General Public License v3.0 or later
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

JavaCPP

Posts with mentions or reviews of JavaCPP. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-04-11.

JNA

Posts with mentions or reviews of JNA. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-04-11.
  • Rust vs Java for simple small GUI apps
    1 project | reddit.com/r/learnrust | 22 May 2022
    In case you haven't used it (assuming that you already know about JNI, for comparison) - https://github.com/java-native-access/jna is about as easy as it gets for native interop. Also, as mentioned in another comment, with the Java FFM (Foreign Function and Memory) API already in preview mode, pretty soon, there will be no external dependencies at all, and Java should be able to interop with any language that can talk to C.
  • Kotlin/Native
    1 project | reddit.com/r/Kotlin | 28 Apr 2022
  • Does Java 18 finally have a better alternative to JNI?
    5 projects | dev.to | 11 Apr 2022
    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.
  • JEP 419: Foreign Function and Memory API
    4 projects | news.ycombinator.com | 29 Mar 2022
    This is about calling into any native operating system APIs, as long as they are callable via C or C++ (which these days means "all" operating system APIs).

    JNI is somewhat harder to use, because you need custom glue on both sides of the border: Some custom classes in Java and some custom code on the C (and C++) side.

    This proposal would remove the need for the glue on the C side and would allow a pure java solution.

    Something like this has existed in third-party form for a while as JNA (https://github.com/java-native-access/jna), but now it's going to be built into the JRE itself (if the proposal passes through review)

  • How run ToS on MacOSX as a java command?
    1 project | reddit.com/r/thinkorswim | 6 Dec 2021
  • Choosing Java as your language for a Machine Learning project
    2 projects | reddit.com/r/java | 4 Nov 2021
    I use JNA https://github.com/java-native-access/jna , as you can write the entire interface in Java faster as well as easier without the need of messing with the complexities of JNI.
  • Creating GUI without framework or library
    2 projects | reddit.com/r/learnjava | 14 Oct 2021
    This (still someone else's code) will give you access to low level operating system APIs. For example, this will let you interact directly with the Windows COM, which lets you define interfaces and implement them: https://github.com/java-native-access/jna
  • Windows COM Object
    1 project | reddit.com/r/Kotlin | 14 Oct 2021
    .. and probably with JNA: https://github.com/java-native-access/jna
  • Can I use ODBC Java?
    1 project | reddit.com/r/javahelp | 8 Aug 2021
    ODBC is a C API. You would need to make C calls from Java. You can use JNI or JNA to access native code.
  • Guide: Running ThinkorSwim natively on Apple Silicone M1 (without Rosetta 2)
    1 project | reddit.com/r/thinkorswim | 20 Jul 2021
    Go to https://github.com/java-native-access/jna and download both "jna-5.8.0.jar" and "jna-platform-5.8.0.jar"

What are some alternatives?

When comparing JavaCPP and JNA you can also consider the following projects:

JNR - Java Abstracted Foreign Function Layer

SWIG - SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.

panama-foreign - https://openjdk.java.net/projects/panama

Lua - Lua is a powerful, efficient, lightweight, embeddable scripting language. It supports procedural programming, object-oriented programming, functional programming, data-driven programming, and data description.

jnativehook - Global keyboard and mouse listeners for Java.

Deep Java Library (DJL) - An Engine-Agnostic Deep Learning Framework in Java

cppimport - Import C++ files directly from Python!

djinni

Cython - The most widely used Python to C compiler

rust-bindgen - Automatically generates Rust FFI bindings to C (and some C++) libraries.