前几天写了一个如何写JNI的文章,说的是调用本地方法,昨天在
ruislan的博客里面看到了他写的一个关于窗体的透明和变换的,里面提到了JNA,然后我去JNA的网站一看,呵呵,还真不错,它不但可以做到窗体的透明和变换,还可以完全调用本地的动态链接库文件,并且还在一定的程度上跨了平台。
以下是官方网站的介绍:
https://jna.dev.java.net
Java Native Access (JNA)
JNA provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java code—no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes. Access is dynamic at runtime without code generation.
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 JNA library uses a small native library stub to dynamically invoke native code. The developer uses a Java interface to describe functions and structures in the target native library. This makes it quite easy to take advantage of native platform features without incurring the high overhead of configuring and building JNI code (overhead would otherwise increase with each supported platform).
The JavaDoc is available online, which includes an overview of specific usage.
NOTE: Sun is not sponsoring this project, even though the package name (com.sun.jna
) might imply otherwise.
This library is provided under the LGPL, version 2.1 or later.
以后只要系统上有的动态链接库,就可以直接调用了,再也不用定义本地方法,然后生成头文件,然后去实现了。这么好的工具,怎么能不去研究一下呢,研究的过程中,我会把它写成文章,与大家分享:)
尽管千里冰封
依然拥有晴空
你我共同品味JAVA的浓香.
posted on 2007-10-24 09:37
千里冰封 阅读(6323)
评论(4) 编辑 收藏 所属分类:
JAVA扩展