简体   繁体   中英

fatal error: jni.h: No such file or directory

I'm trying to recreate this tutorial on Windows: Java Native Interface (JNI)

When I try to compile it I get the following error:

fatal error: jni.h: No such file or directory

 #include <jni.h>

compilation terminated.

My command line is:

gcc -Wl,--add-stdcall-alias -IC:\Program_Files\Java\jdk1.7.0_45\include -IC:\Program_Files\Java\jdk1.7.0_45\include\win32 -shared -o hello.dll HelloJNI.c

I compile in the folder where all the files are.

I am sure that the file "jni.h" in this folder is located:

C:\Program Files\Java\jdk1.7.0_45\include

Does anyone know why the import statement does not work?

Thanks!

Underscore is not the same as space. If jni.h really is in the "program files" directory you should use this command:

gcc -Wl,--add-stdcall-alias -I "C:\\Program Files\\Java\\jdk1.7.0_45\\include" -I "C:\\Program Files\\Java\\jdk1.7.0_45\\include\\win32" -shared -o hello.dll HelloJNI.c

I got the answer:

I just need to use quotation marks, replace the backslash with slash and replace the underscores with spaces.

The command looks like this:

gcc -Wl,--add-stdcall-alias -I"C:/Program Files/Java/jdk1.7.0_45/include" -I"C:/Program Files/Java/jdk1.7.0_45/include/win32" -shared -o hello.dll HelloJNI.c

Thanks to all!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM