A Java library providing efficient, zero-overhead access to native C++ code using JNI and annotations.
JavaCPP is a Java library that provides seamless and efficient access to native C++ code from Java applications. It generates JNI code automatically based on Java annotations, allowing developers to call C++ functions, use C++ classes, and leverage complex C++ features without manual JNI programming. It solves the problem of integrating high-performance native libraries into Java projects with minimal overhead.
Java developers who need to integrate native C++ libraries (e.g., computer vision, machine learning, or system APIs) into their applications, particularly those working on performance-critical or cross-platform projects.
Developers choose JavaCPP because it offers zero-overhead native access compared to alternatives like JNA or SWIG, supports advanced C++ features out-of-the-box, and simplifies deployment with automatic native library loading. Its annotation-based approach reduces boilerplate and integrates smoothly with existing Java build tools.
The missing bridge between Java and native C++
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Generates JNI code with performance equivalent to manually written native functions, ensuring minimal latency for critical operations.
Maps complex C++ constructs like templates, overloaded operators, and virtual functions directly through Java annotations, eliminating manual JNI coding.
Native libraries are loaded automatically from JAR resources via Loader.load(), simplifying deployment across platforms without manual setup.
Includes pre-built interfaces for popular libraries like OpenCV, TensorFlow, and FFmpeg, accelerating integration and reducing boilerplate.
Requires a C++11 compiler and additional setup for platforms like Android (via NDK), complicating builds in environments without native toolchains.
Bugs in native code can easily crash the JVM, and debugging requires familiarity with advanced tools like the HotSpot VM troubleshooting guide.
Mapping intricate C++ types, as shown in the VectorTest example with nested templates, demands deep understanding of both languages and careful annotation use.
JavaCPP is an open-source alternative to the following products:
SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.
C++/CLI is a language specification that enables interoperability between native C++ and Microsoft's .NET Framework, allowing developers to write managed code.
JNA (Java Native Access) is a Java library that provides easy access to native shared libraries without writing JNI code, allowing Java programs to call native functions.
Cython is a programming language that makes writing C extensions for Python as easy as Python itself, used to speed up Python code by compiling it to C.
JNR (Java Native Runtime) is a Java library for native code integration, offering an alternative to JNI with better performance and easier API for calling native functions.