Mirrors and controls Android devices from a computer over USB or TCP/IP, with no root or on-device app required.
facebookincubator/fbjni
A C++ helper library that simplifies calling Java code from native code through the Java Native Interface (JNI).
- Stars
- 337
- Forks
- 53
- Open issues
- 17
- Last commit
- 6 hours ago
What is it?
fbjni wraps the raw Java Native Interface in C++ helpers, so native code can call Java methods, fields and constructors with less boilerplate. It handles JNI local and global reference lifetimes automatically and translates exceptions between Java and C++ in both directions, so developers do not have to check exception state after every call.
Type conversion is handled by the library as well. Method descriptors are inferred from C++ signatures, and common types such as std::string convert to and from Java types. Java classes are mapped to C++ structs that derive from a JavaClass template and declare their Java descriptor.
The helpers were built to support cross-platform mobile code on Android, but the design has no Android-specific dependencies and works with any Java VM that supports JNI. The project includes documentation covering setup for Android builds, a quick reference of features and the rationale for using a JNI wrapper.
Key features
- 01Automatic management of JNI local and global references.
- 02Two-way translation of Java exceptions and C++ exceptions.
- 03Method descriptors inferred from C++ function signatures.
- 04Automatic conversion between std::string and Java strings.
- 05Java classes mapped to C++ types through a JavaClass template.
Use cases
- Calling Java APIs from a shared C++ codebase in an Android app.
- Embedding native C++ modules in any JVM application that uses JNI.
- Reducing manual reference counting and exception checks in existing JNI code.
Quick start
- 1
Read the quick reference for copy-paste usage examples in docs/quickref.md
- 2
Follow the Android build setup guide in docs/android_setup.md
In collections
Topics
FAQ
- What is fbjni?
- A C++ helper library that simplifies calling Java code from native code through the Java Native Interface (JNI). fbjni wraps the raw Java Native Interface in C++ helpers, so native code can call Java methods, fields and constructors with less boilerplate. It handles JNI local and global reference lifetimes automatically and translates exceptions between Java and C++ in both directions, so developers do not have to check exception state after every call.
- Is fbjni free to use? What license does it have?
- fbjni is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is fbjni still maintained?
- Actively maintained. The last commit to fbjni was on Oct 22, 2026.
- What can I use fbjni for?
- Calling Java APIs from a shared C++ codebase in an Android app. Embedding native C++ modules in any JVM application that uses JNI. Reducing manual reference counting and exception checks in existing JNI code.
- How do I install fbjni?
- Read the quick reference for copy-paste usage examples in docs/quickref.md Follow the Android build setup guide in docs/android_setup.md
- Where can I get fbjni?
- The source code and installation instructions are on GitHub: https://github.com/facebookincubator/fbjni
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A C audio playback and capture library distributed as a single source file, with no external dependencies.
A cross-platform C++ image and video filter library that runs on OpenGL/ES, with beauty and face-based effects.
A cross-platform Java game development framework built on OpenGL ES for desktop, Android, web, and iOS games.
Google's open-source SDK for building natively compiled mobile, web, and desktop apps from a single Dart codebase.
A framework for building native Android and iOS apps using React, with JavaScript UI rendered by native platform components.