Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time

BEWARE: This project hasn't been maintained since 2015. An effort to refresh it (and JNAerator) is ongoing (Nov 2022) and 0.8.0-SNAPSHOT contains a sneak peek of it, with no guarantees.


Maven Central Build Status (Travis: Linux) ![Build Status (AppVeyor: Windows)]( build) Join the chat at

BridJ is a Java / native interoperability library that focuses on speed and ease of use.

It is similar in spirit to JNA (dynamic bindings that don't require any native compilation, unlike JNI), but was designed to support C++, to be blazing fast (thanks to dyncall + hand-optimized assembly tweaks) and to use modern Java features.

A comprehensive documentation is available on its Wiki.

It was previously hosted on ochafik/nativelibs4java.

Quick links

Note: the Wiki is being refreshed.


git clone
cd BridJ
mvn clean install

Iterate on native code:

mvn native:javah
./BuildNative && mvn surefire:test



Assuming you have docker:

# One-off to let Docker use QEMU to run exotic architectures.
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes --credential yes

# Install the cross-compiler for Windows
# sudo apt install mingw-w64
brew install mingw-w64


# Get JDK for Mac ARM64 & X64
wget{x64,aarch64}_bin.tar.gz && \
  tar zxvf openjdk-19_macos-aarch64_bin.tar.gz && mv jdk-19.jdk{,-darwin_arm64} && \
  tar zxvf openjdk-19_macos-x64_bin.tar.gz && mv jdk-19.jdk{,-darwin_x64} \

# Get JDK for Windows X64
wget && \
    unzip && mv jdk-19{,-windows_x64}

# Get JDK for Windows ARM64
wget && \
  tar zxvf openjdk-19_macos-aarch64_bin.tar.gz && mv jdk-16.0.2+7{,-windows_arm64}

wget && \

Cross-build commands

# Mac host: build Mac M1 & Intel binaries
ARCH=x64 ./BuildNative -DFORCE_JAVA_HOME=$PWD/../jdk-19.jdk-darwin_x64/Contents/Home
ARCH=arm64 ./BuildNative -DFORCE_JAVA_HOME=$PWD/../jdk-19.jdk-darwin_arm64/Contents/Home

# Mac or Linux host: build Windows X64 & X86 binaries w/ MinGW-w64
OS=windows ARCH=x64 ./BuildNative \
  -DCMAKE_TOOLCHAIN_FILE=$PWD/mingw-w64-x86_64.cmake \
OS=windows ARCH=x86 ./BuildNative \
  -DCMAKE_TOOLCHAIN_FILE=$PWD/mingw-w64-i686.cmake \

# Mac or Linux host: build & test Linux x86, x64, arm64, arm binaries inside Docker + QEMU:
# TODO: look at armel situation (no openjdk?)
         ./scripts/ linux/x86_64   debian:bullseye-slim           bridj-linux-x64
ARCH=x86 ./scripts/ linux/i386     i386/debian:bullseye-slim      bridj-linux-x86
         ./scripts/ linux/arm64    arm64v8/debian:bullseye-slim   bridj-linux-arm64
         ./scripts/ linux/arm/v7   arm32v7/debian:bullseye-slim   bridj-linux-arm
         ./scripts/ linux/ppc64le  ppc64le/debian:bullseye-slim   bridj-linux-ppc64le
#        ./scripts/ linux/arm/v6 balenalib/rpi-raspbian:bullseye bridj-linux-armel

# Windows x64 host (UNTESTED): build Windows X64 & ARM64 binary
ARCH=x64 ./BuildNative
ARCH=arm64 ./BuildNative -DFORCE_JAVA_HOME=$PWD/../jdk-16.0.2+7-windows_arm64


mvn dependency:build-classpath -DincludeScope=test -Dmdep.outputFile=deps-classpath-test.txt
DEBUG=1 mvn clean test-compile

# Or gdb --args java ...
lldb -- java -cp \
  target/generated-resources:target/generated-test-resources:target/test-classes:target/classes:$( cat deps-classpath-test.txt ) \
  org.junit.runner.JUnitCore \


mvn format


Please use the mailing-list and file bugs.