22 lines
499 B
Rust
22 lines
499 B
Rust
|
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()
|
||
|
}
|