Java知识分享网 - 轻松学习从此开始!    

Java知识分享网

Java1234官方群25:java1234官方群17
Java1234官方群25:838462530
        
SpringBoot+SpringSecurity+Vue+ElementPlus权限系统实战课程 震撼发布        

最新Java全栈就业实战课程(免费)

springcloud分布式电商秒杀实战课程

IDEA永久激活

66套java实战课程无套路领取

锋哥开始收Java学员啦!

Python学习路线图

锋哥开始收Java学员啦!
当前位置: 主页 > Java文档 > Java基础相关 >

Java Native Interface (JNI) - Java Programming Tutorial PDF 下载


分享到:
时间:2021-05-17 09:44来源:http://www.java1234.com 作者:转载  侵权举报
Java Native Interface (JNI) - Java Programming Tutorial PDF 下载
失效链接处理
Java Native Interface (JNI) - Java Programming Tutorial PDF 下载


本站整理下载:
提取码:sg9h 
 
 
相关截图:
 
主要内容:


The static initializer invokes System.loadLibrary() to load the native library "hello" (which contains a native method called sayHello()) during
the class loading. It will be mapped to "hello.dll" in Windows; or "libhello.so" in Unixes/Mac OS X. This library shall be included in Java's library
path (kept in Java system variable java.library.path). You could include the library into Java's library path via VM argument -
Djava.library.path=/path/to/lib. The program will throw a UnsatisfiedLinkError if the library cannot be found in runtime.
Next, we declare the method sayHello() as a native instance method, via keyword native which denotes that this method is implemented in
another language. A native method does not contain a body. The sayHello() shall be found in the native library loaded.
The main() method allocates an instance of HelloJNI and invoke the native method sayHello().
Step 2: Compile the Java Program HelloJNI.java & Generate the C/C++ Header File HelloJNI.h
Starting from JDK 8, you should use "javac -h" to compile the Java program AND generate C/C++ header file called HelloJNI.h as follows:
> javac -h . HelloJNI.java
The "-h dir" option generates C/C++ header and places it in the directory specified (in the above example, '.' for the current directory).
Before JDK 8, you need to compile the Java program using javac and generate C/C++ header using a dedicated javah utility, as follows. The javah
utility is no longer available in JDK 10.
> javac HelloJNI.java
> javah HelloJNI
Inspect the header file HelloJNI.h:

 

------分隔线----------------------------

锋哥公众号


锋哥微信


关注公众号
【Java资料站】
回复 666
获取 
66套java
从菜鸡到大神
项目实战课程

锋哥推荐