jni_rs/mylib/src/lib.rs

22 lines
499 B
Rust
Raw Normal View History

2022-02-22 12:29:33 +00:00
use jni::objects::{JClass, JString};
use jni::sys::jstring;
use jni::JNIEnv;
#[no_mangle]
pub extern "system" fn Java_me_ehlxr_HelloWorld_hello(
env: JNIEnv,
_class: JClass,
input: JString,
) -> jstring {
let input: String = env
.get_string(input)
.expect("Couldn't get java string!")
.into();
let output = env
.new_string(format!("Hello, {}! from Rust...111", input))
.expect("Couldn't create java string!");
output.into_inner()
}