JNA(Java Native Access )提供一组Java工具类用于在运行期动态访问系统本地库(native library:如Window的dll)而不需要编写任何Native/JNI代码。开发人员只要在一个java接口中描述目标native library的函数与结构,JNA将自动实现Java接口到native function的映射。
官方网站:https://jna.dev.java.net/
下载地址:https://jna.dev.java.net/
A small set of Java language utilities and conventions for dynamically accessing native libraries (for example, .dll's on Windows or .so's on Solaris) on any supported platform without writing anything but Java code—no JNI or native code is required, and access is dynamic at runtime without code generation. This functionality is comparable to Windows' pinvoke and Python's ctypes.
The JNA library uses a small native library stub to dynamically invoke native code without the developer having to write JNI code. The developer describes functions and structures from the target native library in a Java interface. From his perspective, he interacts only with Java code. This makes it quite easy to take advantage of native platform features without getting into the major hassle of writing your own JNI code. It also facilitates implementing cross-platofrm features withing incurring the high overhead of configuring and building JNI for multiple platforms.
JNA's design aims to provide native access in a natural way with a minimum of effort. No boilerplate or generated code is required. While some attention is paid to performance, correctness and ease of use take priority.
The JavaDoc is available online, which includes an overview of specific usage. |