This repository shows how to use Java 25 FFM API with a rust library.
Install Rust is required to build the native library under the rust_lib folder
Build the native library
cd rust_lib
cargo build --release
Java 25 is required to build the demo application under the ffm_app folder.
Build the demo application
cd ffm_app
./mvnw clean compile
Run the demo application (from the ffm_app folder) With Maven
./mvnw exec:exec -Daction=ACTION
With java command
java -Djava.library.path=../rust_lib/target/release --enable-native-access=fr.flob.ffm -p target/classes -m fr.flob.ffm/fr.flob.ffm.App ACTION
With ACTION is one of the following:
hellorun the simple hello from rustreadcall rust function that read on a shared memorywritecall rust function that read and modify on a shared memory
-Djava.library.path: folder where the native library is located--enable-native-access: enable Java Native Access for the application module-p: module path of the application-m: module main class of the application