I want to get two functions from a dynamic shared object library [developped with C/C++]. To call this DLL from my java application, I have used Java JNI. However, after compiling the Java application I find the compiler has generated a headerfile jni.h. I added the file in my DLL, but when I tried compiling the DLL project, I got the following compilation error:
fatal error: jni.h: No such file or directory #include
I tried to include the header file directories :
/I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32"
Without any success
the header file JNIServerLib.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class jniserver_JNIServer */
#ifndef _Included_jniserver_JNIServer
#define _Included_jniserver_JNIServer
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: jniserver_JNIServer
* Method: BZ_receiving
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_jniserver_JNIServer_BZ_receiving
(JNIEnv *, jobject);
/*
* Class: jniserver_JNIServer
* Method: BZ_sending
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_jniserver_JNIServer_BZ_sending
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
Simple java program JNIServer.java
public class JNIServer {
public native void BZ_receiving();
public native void BZ_sending();
/**
* @param args the command line arguments
*/
static{
System.loadLibrary("JNIServer");
}
public static void main(String[] args) {
new JNIServer().BZ_receiving();
new JNIServer().BZ_sending();
}
}
JAVA_HOME
environment variable declared, and does it point to the correct directory for the JDK? – Petesh