auto-jni

Crates.ioauto-jni
lib.rsauto-jni
version0.0.3
sourcesrc
created_at2024-11-27 19:39:16.424779
updated_at2024-11-29 03:39:24.108815
descriptionAutomatically create bindings to Java through JNI
homepage
repositoryhttps://github.com/Sha-dos/auto-jni
max_upload_size
id1463551
size29,884
Nolan Peterson (Sha-dos)

documentation

README

Auto JNI

Automatically create bindings to Java through JNI

This was created to simplify created bindings for frcrs and to make it easier to create bindings for other projects.

Auto JNI is a heavy work in progress and their are many features still being implemented.

  • Initialize Classes
  • Call Methods (static and instance)
  • Create enums
  • Improve API
  • Add more examples
  • Add more documentation
  • Add more tests
  • Add more error handling
  • Add more logging

Example

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");
}
Commit count: 24

cargo fmt