- JDK 22+ (required for Panama FFM native access)
- Gradle (wrapper included, no install needed)
For native library builds:
- CMake 3.16+
- GCC (Linux) or MSVC (Windows)
If you don't need to recompile the native C library (pre-compiled binaries are
already included in src/main/resources/native/):
./gradlew clean assembleThe JAR is output to build/libs/FasterForest-<version>.jar.
The native library provides C-based forest prediction via Panama FFM. Pre-compiled binaries for Linux and Windows (x86_64) are committed to the repo, so you only need to rebuild them if you change the C source code.
./build-linux.shThis script:
- Builds the native
libfasterforest.sovia CMake - Copies it to
src/main/resources/native/linux-x86_64/fasterforest.so - Builds the JAR with
./gradlew clean assemble
Or manually:
cd native
mkdir -p build && cd build
cmake ..
make
cp libfasterforest.so ../../src/main/resources/native/linux-x86_64/fasterforest.so
cd ../..
./gradlew clean assembleWith MSVC (Visual Studio):
cd native
mkdir build && cd build
cmake .. -G "Visual Studio 17 2022"
cmake --build . --config Release
copy Release\fasterforest.dll ..\..\src\main\resources\native\windows-x86_64\fasterforest.dll
cd ..\..
gradlew clean assembleWith MinGW:
cd native
mkdir build && cd build
cmake .. -G "MinGW Makefiles"
cmake --build .
copy libfasterforest.dll ..\..\src\main\resources\native\windows-x86_64\fasterforest.dll
cd ..\..
gradlew clean assembleTo build a JAR containing native libraries for both platforms:
- Build the native library on each platform (or cross-compile)
- Place the binaries in the resource tree:
src/main/resources/native/linux-x86_64/fasterforest.sosrc/main/resources/native/windows-x86_64/fasterforest.dll
- Run
./gradlew clean assemble
The JAR bundles all native libraries found in the resource tree.
At runtime, NativeLoader extracts the correct one for the current OS/arch.
- AVX2 SIMD code is compiled only on x86_64. Runtime CPUID detection falls back to scalar if AVX2 is not available on the target machine.
- The native library is optional. If loading fails, FasterForest falls back to pure Java prediction automatically.
- For development, you can point to a local native library with:
-Dfasterforest.native.path=/path/to/libfasterforest.so