What is the native keyword in Java for?

Minimal runnable example Main.java public class Main { public native int square(int i); public static void main(String[] args) { System.loadLibrary(“Main”); System.out.println(new Main().square(2)); } } Main.c #include <jni.h> #include “Main.h” JNIEXPORT jint JNICALL Java_Main_square( JNIEnv *env, jobject obj, jint i) { return i * i; } Compile and run: sudo apt-get install build-essential openjdk-7-jdk export JAVA_HOME=’/usr/lib/jvm/java-7-openjdk-amd64′ … Read more

tech