您的位置:首页 > 编程语言 > Java开发

java native方法

2007-09-18 13:32 387 查看
java native方法是指本地方法,当在方法中调用一些不是由java语言写的代码或者在方法中用java语言
直接操纵计算机硬件时要声明为native方法。

java中,通过JNI(Java Native Interface,java本地接口)来实现本地化。

参考资料:

1.JAVA中native方法 http://karoii.bokee.com/5869823.html
2.JNI http://wiki.matrix.org.cn/Wiki.jsp?page=JNI
3.用JNI调用C或C++动态联接库原来如此简单 http://blog.matrix.org.cn/david_w_johnson/
4.http://myblog.workgroup.cn/blogs/java/
Native方法一般用于两种情况:

1)在方法中调用一些不是由java语言写的代码。

2)在方法中用java语言直接操纵计算机硬件。

Other than being implemented in native code, native methods are like all other methods: they

can be overloaded, overridden, final, static, synchronized, public, protected, or private. A

native method cannot, however, be declared abstract or strictfp.

如果使用了native方法也就丢失了java的方便性和安全性。Native方法的执行依赖于JVM的设计者,比如

在sun的JVM中,可以通过JNI(Java Native Interface) API接口来实现本地化。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: