register_vnc_natives

Function register_vnc_natives 

Source
pub fn register_vnc_natives(
    env: &mut JNIEnv<'_>,
    main_service_class: &str,
    input_service_class: &str,
) -> Result<(), String>
Expand description

Registers VNC native methods with the specified Java classes.

This function uses JNI’s RegisterNatives to dynamically bind Rust functions to Java native methods, allowing the same library to work with any package name.

§Arguments

  • env - The JNI environment
  • main_service_class - Fully qualified class name (e.g., “com/example/app/MainService”)
  • input_service_class - Fully qualified class name (e.g., “com/example/app/InputService”)

§Returns

Ok(()) if registration succeeds, Err with description otherwise.

§Example

#[no_mangle]
pub extern "system" fn JNI_OnLoad(vm: JavaVM, _: *mut c_void) -> jint {
    let env = vm.get_env().unwrap();
    register_vnc_natives(
        &mut env,
        "com/mycompany/vnc/MainService",
        "com/mycompany/vnc/InputService",
    ).expect("Failed to register natives");
    jni::sys::JNI_VERSION_1_6
}