first commit
This commit is contained in:
commit
e2c095af41
34 changed files with 667 additions and 0 deletions
BIN
java/HelloWorld.class
Normal file
BIN
java/HelloWorld.class
Normal file
Binary file not shown.
21
java/HelloWorld.h
Normal file
21
java/HelloWorld.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class HelloWorld */
|
||||
|
||||
#ifndef _Included_HelloWorld
|
||||
#define _Included_HelloWorld
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: HelloWorld
|
||||
* Method: callRustFunction
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_HelloWorld_callRustFunction
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
17
java/HelloWorld.java
Normal file
17
java/HelloWorld.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
// java/HelloWorld.java
|
||||
public class HelloWorld {
|
||||
static {
|
||||
System.loadLibrary("rust_interop");
|
||||
}
|
||||
|
||||
public native void callRustFunction();
|
||||
|
||||
public String getGreeting() {
|
||||
return "Hello from Java!";
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
HelloWorld hw = new HelloWorld();
|
||||
hw.callRustFunction();
|
||||
}
|
||||
}
|
14
java/Main.java
Normal file
14
java/Main.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
// java/Main.java
|
||||
public class Main {
|
||||
static {
|
||||
System.loadLibrary("rust_jni_example");
|
||||
}
|
||||
|
||||
private static native void call_java_from_rust();
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Calling Rust function...");
|
||||
call_java_from_rust();
|
||||
System.out.println("Rust function call completed.");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue