Cannot open include file "jni.h", no such file or directory

I am using a simple JNI example as indicated in

http://java.sun.com/docs/books/jni/html/start.html

In the second last stage, when the source C is generated,

the following command is used ---

C: \ Program Files \ Java \ jdk1.6.0_21> cl -IC: \ Program Files \ Java \ jdk1.6.0_21 \ include -IC: \ Program Files \ Java \ jdl1.6.0_21 \ include \ win32 - MD -LD Callbacks.c -FeCallbacks.dll

I get the following error:

"Cannot open include file" jni.h ", no such file or directory."

But jni.h exists in the java / jdk1.6.0_21 / include folder.

How to remove this error?

+4
source share
2 answers

Since the path contains u spaces, you need to enclose the path inside "" as cl -IC: \ Program Files \ Java \ jdk1.6.0_21 \ includes e -I "C: \ Program Files \ Java \ jdl1.6.0_21 \ include \ win32 "-MD -LD Callbacks.c -FeCallb acks.dll

+3
source

If the path contains spaces, you must specify the path. In my case, the command is as follows:

cl -I"C:\Program Files\Java\jdk1.8.0_91\include" -I"C:\Program Files\Java\jdk1.8.0_91\include\win32" -LD HelloWorldImp.c -Fehello.dll 

Hope this helps.

0
source

All Articles