本示例展示JNI的基本示例,helloworld级别的,不过是用JNI_OnLoad映射的方式. 直接看代码,先看包含native method的Person.java的代码: package helloworld; /** * author : Zhou Shenshen * date : 2016.7.16 * desc : It is a class to show how to use JNI. * 演示调用JNI本地方法的写法和加载动态库 * email : zhouss@iPanel
下面看一个实例,如下: public class TestJNI { static { System.loadLibrary("diaoyong"); // 程序在加载时,自动加载libdiaoyong.so库 } public native void set(int value); // 声明原生函数.注意要添加native关键字 public native int get(); public static void main(String[] args) { TestJNI tes