Crates.io | auto-jni |
lib.rs | auto-jni |
version | 0.0.3 |
source | src |
created_at | 2024-11-27 19:39:16.424779 |
updated_at | 2024-11-29 03:39:24.108815 |
description | Automatically create bindings to Java through JNI |
homepage | |
repository | https://github.com/Sha-dos/auto-jni |
max_upload_size | |
id | 1463551 |
size | 29,884 |
This was created to simplify created bindings for frcrs and to make it easier to create bindings for other projects.
Example.java
package com.example;
class Example {
public static int add(int a, int b) {
return a + b;
}
}
build.rs
fn main() {
println!("cargo:rerun-if-changed=build.rs");
let out = env::var("OUT_DIR").unwrap();
let file = Path::new(&out).join("bindings.rs");
let class_name = vec![
"com.example.Example"
];
let class_path = Some("build".to_string());
let options = vec![
"-Djava.class.path=build".to_string(),
];
generate_bindings_file(class_name, class_path, &*file, Some(options)).expect("Failed to generate bindings");
}