主题:java与c混合编程
java文件:
class jniexample
{
static{System.loadLibrary("testjni");
}
private native void testjni();
public void test()
{
testjni();
}
public static void main(String[] args)
{
jniexample haha=new jniexample();
haha.test();
}
}
c文件:
#include <stdio.h>
#include <jni.h>
#include "F:\Jproject\jniexample.h"
JNIEXPORT void JNICALL Java_jniexample_testjni(JNIEnv *, jobject )
{
printf("hello\n");
}
如题,已经生成了testjni.dll文件,但最后运行的时候
出现问题:
exception in thread "main" java.lang.UnsatisfiedLinkError:testjni
at jniexample.testjni(Native Method)
at jniexample.test(jniexample.java:8)
at jniexample.main(jniexample.java:15)
class jniexample
{
static{System.loadLibrary("testjni");
}
private native void testjni();
public void test()
{
testjni();
}
public static void main(String[] args)
{
jniexample haha=new jniexample();
haha.test();
}
}
c文件:
#include <stdio.h>
#include <jni.h>
#include "F:\Jproject\jniexample.h"
JNIEXPORT void JNICALL Java_jniexample_testjni(JNIEnv *, jobject )
{
printf("hello\n");
}
如题,已经生成了testjni.dll文件,但最后运行的时候
出现问题:
exception in thread "main" java.lang.UnsatisfiedLinkError:testjni
at jniexample.testjni(Native Method)
at jniexample.test(jniexample.java:8)
at jniexample.main(jniexample.java:15)