だから、私はJNIが初めてで、簡単なハローワードの例に従っていますが、エラーが発生し続けますUnsatisfiedLinkError
。私は何を間違っていますか?ここに私の.hファイルがあります:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class JNITEST_jnihellonative */
#ifndef _Included_JNITEST_jnihellonative
#define _Included_JNITEST_jnihellonative
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: JNITEST_jnihellonative
* Method: hellofromc
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_JNITEST_jnihellonative_hellofromc(JNIEnv *,jobject);
#ifdef __cplusplus
}
#endif
#endif
.c ファイル
#include <jni.h>
#include<stdio.h>
#include<windows.h>
#include "jnihellonative.h"
JNIEXPORT void JNICALL
Java_JNITESTS_jnihellonative_hellofromc(JNIEnv *env, jobject obj){
printf("Hello World");
return;
}
Java メインクラス
package JNITEST;
public class Jnihello {
public static void main(String[] args) {
jnihellonative jniprint = new jnihellonative();
jniprint.hellofromc();
}
}
Java クラス
package JNITEST;
public class jnihellonative {
public native void hellofromc();
static{
System.load("C:\\Users\\Kevin\\Documents\\NetBeansProjects\\JniHelloTest.dll");
}
}
このエラーが発生し続けます
Exception in thread "main" java.lang.UnsatisfiedLinkError: JNITEST.jnihellonative.hellofromc()V
at JNITEST.jnihellonative.hellofromc(Native Method)
at JNITEST.Jnihello.main(Jnihello.java:19)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
System.load() と System.loadLibrary() を使用してみましたが、同じエラーが発生します。