public class hellonative
{
public native static void greeting();
static
{
system.loadlibrary("hellonative");
}
}
#include
#include"hellonative.h"
{
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 hellonativetestg
(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 hellonativetestg