2007年1月12日

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接口来实现本地化。