Java - JNI Studying 0-1

来源:互联网 发布:下载看图王软件 编辑:程序博客网 时间:2024/06/05 14:58

I am luckly to find a good book about Java Native Interface today.What's more, I met so much issues of android application issues these days. So it's necessary for me to study the Java JNI in detail.


I will introduce the JNI in this Lesson, and will show a simple example of JNI in next lesson. Form lesson 3 to 10, I will consititute a programmer's guide that gives a board overview of number of JNI features. Lesson 11 to 13 present the definitive specification for all JNI types and fucntions.

so let's do it now.


The fist lesson,Introduce To Java Native Interface


The Java Native Interface(JNI) is a powerful feature of the Java platfrom. Applications that use the JNI can incorporate native code written in programming languages such C and C++, as well as code written in the Java programming language.


As a part of the java virtual machine implementation, the JNI is a two-way interface that allows java applications to invoke native code and vice versa. And the JNI can support two types of native coee: native libraries & native applications.


Remember that once an application uses the JNI, it risks losing two benefits of the java platform: first, java applications that depend on the JNI can not longer readily run on multiple host environments. second, while the java programming language is type-safe and secure, native languages such as C/C++ are not. As a result, you must use extra care when writting applications using the JNI.


As we mentioned in the last section, applications that use the JNI have inherent disadvantages when compared with applications written strictly in the java programming language; so before you embark on a project using the JNI, it's worth taking a step back to investigate whether there are alternative solutions that are more appropriate. sometimes, however, you may find it necessary for a java application to communicate with native code that resides in the same process. this is when the JNI becomes useful.

原创粉丝点击