Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
792 views
in Technique[技术] by (71.8m points)

java - jni.h: no such file or directory

I'm using Code::Blocks in windows.

I created a dll project trying to get some JNI practice.

In my .h file generated by javah, there's #include jni.h, but when I try to compile it, it keeps saying jni.h: no such file or directory.

I think it has something to do with classpath, but I don't know what it is! It's probably setting that I have to change in Code::Blocks

Could someone please help me to fix it? many thanks

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Vector3D */

#ifndef _Included_Vector3D
#define _Included_Vector3D
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     Vector3D
 * Method:    magnitude
 * Signature: ()D
 */
JNIEXPORT jdouble JNICALL Java_Vector3D_magnitude
  (JNIEnv *, jobject);

/*
  * Class:     Vector3D
 * Method:    mult
 * Signature: (LVector3D;I)LVector3D;
 */
JNIEXPORT jobject JNICALL Java_Vector3D_mult
  (JNIEnv *, jobject, jobject, jint);

/*
 * Class:     Vector3D
 * Method:    equals
 * Signature: (LVector3D;)Z
 */
JNIEXPORT jboolean JNICALL Java_Vector3D_equals
  (JNIEnv *, jobject, jobject);

/*
 * Class:     Vector3D
 * Method:    dotProduct
 * Signature: (LVector3D;LVector3D;)D
 */
JNIEXPORT jdouble JNICALL Java_Vector3D_dotProduct
  (JNIEnv *, jclass, jobject, jobject);

/*
 * Class:     Vector3D
 * Method:    makeNormalized
 * Signature: (LVector3D;)LVector3D;
 */
JNIEXPORT jobject JNICALL Java_Vector3D_makeNormalized
  (JNIEnv *, jclass, jobject);

/*
 * Class:     Vector3D
 * Method:    crossProduct
 * Signature: (LVector3D;LVector3D;)LVector3D;
 */
JNIEXPORT jobject JNICALL Java_Vector3D_crossProduct
  (JNIEnv *, jclass, jobject, jobject);

#ifdef __cplusplus
}
#endif
#endif

EDIT:
So I did Settings-->Compiler and debugger-->Search directories-->and added "$(JAVA_HOME)include" and "$(JAVA_HOME)includewin32" under Compiler, and it was able to find it!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You have to add the JDK path to the include path, so the compiler knows the location of the file.

Windows:

/I "$(JAVA_HOME)include" /I "$(JAVA_HOME)includewin32"

Linux:

-I"${JAVA_HOME}/include" -I"${JAVA_HOME}/include/linux"

Mac:

-I"${JAVA_HOME}/include" -I"${JAVA_HOME}/include/darwin"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...