{"id":57754,"library":"jni","title":"JNI","description":"Rust bindings to the Java Native Interface (JNI) for calling Java code from Rust and vice versa.","status":"active","version":"0.22.4","language":"rust","source_language":null,"source_url":"https://github.com/jni-rs/jni-rs","tags":["jni","java","ffi","interop"],"install":[{"cmd":"# Cargo.toml\n[dependencies]\njni = \"0.22.4\"","lang":"toml","label":"Cargo.toml"},{"cmd":"cargo add jni","lang":"bash","label":"cargo add"}],"dependencies":[],"imports":[{"symbol":"JNIEnv","correct":"use jni::JNIEnv;"}],"quickstart":{"code":"use jni::JNIEnv;\nuse jni::objects::JClass;\n\n#[no_mangle]\npub extern \"system\" fn Java_HelloWorld_hello(env: JNIEnv, _class: JClass) {\n    let output = env.new_string(\"Hello from Rust!\").unwrap();\n    env.call_static_method(\"java/lang/System\", \"out\", \"()Ljava/io/PrintStream;\", &[]).unwrap();\n}","lang":"rust","description":"Defines a JNI function that creates a Java string and prints it via System.out."},"warnings":[{"fix":"Set crate-type = [\"cdylib\"] in Cargo.toml and ensure function names match Java package paths.","message":"JNI functions must have the exact naming convention and be compiled as a cdylib.","severity":"gotcha","affected_versions":">=0.20.0"}],"env_vars":null,"search_vec":"'bind':3 'call':11 'code':13 'ffi':21 'interfac':8 'interop':22 'java':6,12,20 'jni':1,9,19 'nativ':7 'rust':2,15 'versa':18 'vice':17","created_at":"2026-06-16T15:56:14.420435+00:00","updated_at":"2026-06-16T15:56:14.420435+00:00","problems":[],"ecosystem":"crates","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/jni-rs/jni-rs","github":"https://github.com/jni-rs/jni-rs","docs":"https://docs.rs/jni/","changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["other"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-16","next_check":"2026-12-13","install_tag":null}}