Skip to content

seanjensengrey/rust-jna-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Java JNA Example

This is an example of creating a dynamic library in Rust that exposes a C ABI and called via JNA. Orginally based on this gist.

git clone https://github.com/seanjensengrey/rust-jna-example.git

Build and Run Example

cd rust-jna-example
mvn compile
rustc treble.rs
mvn exec:java -Dexec.mainClass="rustjna.Treble"

To install build dependencies on a Mac via Homebrew

brew install maven
brew install multirust
multirust default stable
multirust update

Output

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building TrebleJna 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ test ---
trebling: 10 30
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.497 s
[INFO] Finished at: 2016-02-19T12:46:32-05:00
[INFO] Final Memory: 9M/245M
[INFO] ------------------------------------------------------------------------

About

Calling a rust library from Java using JNA

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published