千里冰封
JAVA 浓香四溢
posts - 151,comments - 2801,trackbacks - 0
前几天写了一个如何写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扩展

FeedBack:
# re: JNA介绍
2007-10-25 08:55 | 阿蜜果
官方网站的介绍的那部分字体好刺眼啊,呵呵
关注起JNA来了。。。  回复  更多评论
  
# re: JNA介绍
2007-10-25 09:06 | 千里冰封
呵呵,怎么变成这样了,在FF下面看到不是这样子的啊  回复  更多评论
  
# re: JNA介绍
2007-11-27 20:34 | 隔叶黄莺
我研究并写过两篇 JNative 调用动态库的日志,也是能跨平台的。直接调用,不用写自己的动态库。有时间也研究一下JNA,希望能与楼主共勉。  回复  更多评论
  
# re: JNA介绍
2008-04-05 13:33 | fenixshadow
支持支持,jni根本不敢用,太麻烦了。

还不如在java中把脚本写死:vb\perl等,然后直接调用。

咱也看看jna,希望好用  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: