<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
public class HelloNative
{
public native static void greeting();
static
{
System.loadLibrary("HelloNative");
}
}
#include
#include"HelloNative.h"
JNIEXPORT void JNICALL Java_HelloNative_greeting
(JNIEnv * env, jclass cl)
{
printf("hello.native world");
}
class HelloNativeTest
{
public static void main(String arg[])
{
HelloNative.greeting();
}
}
第一:编写HelloNative.java源代码
第二:javac helloNative.java
第三:javah helloNative
第四:编写HelloNative.c
第五:cl -I d:/jdk/include -I d:/jdk/include/win32 -LD HelloNative.c 生成动态链接库
第六:编写HelloNativeTest.java
第七:javac HelloNativeTest.java
第八:java HelloNativeTest
大功告成!
java本地调用-Native(源代码)
最新推荐文章于 2025-08-09 15:58:26 发布