JNI_OnLoad

Function JNI_OnLoad 

Source
#[unsafe(no_mangle)]
pub extern "system" fn JNI_OnLoad( jvm: JavaVM, _reserved: *mut c_void, ) -> jint
Expand description

JNI_OnLoad entry point - called when the library is loaded.

This function reads class names from Java system properties and registers native methods automatically. Set these properties BEFORE calling System.loadLibrary():

static {
    System.setProperty("rustvnc.main_service_class", "com/elo/vnc/MainService");
    System.setProperty("rustvnc.input_service_class", "com/elo/vnc/InputService");
    System.setProperty("rustvnc.log_tag", "MyApp-VNC");  // Optional
    System.loadLibrary("rustvncserver_android");
}

If properties are not set, JNI_OnLoad will store the JavaVM but skip native registration. You can then call register_vnc_natives() manually from a wrapper crate’s JNI_OnLoad.