Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 933
anmi Avatar asked Jan 12 '23 23:01

anmi


1 Answers

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

like image 71
Joni Avatar answered Jan 17 '23 17:01

Joni