polyglot_jni/src/main/java/io/speice/Polyglot.java

26 lines
843 B
Java

package io.speice;
import java.lang.reflect.Method;
public class Polyglot {
static {
// Because CMake will process this file to generate native headers, we can't
// import NativeLoader directly (CMake won't have it on the compile path when
// calling javac).
// Instead, use reflection to find it. Because this is only run once, the cost
// of reflection is negligible.
try {
Class<?> c = Class.forName("org.scijava.nativelib.NativeLoader");
Method m = c.getDeclaredMethod("loadLibrary", String.class, String[].class);
m.invoke(null, "polyglot", null);
} catch (Exception e) {
}
}
public static native String getMessage();
public static void main(String[] args) {
System.out.println(Polyglot.getMessage());
}
}