Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make jni.h be found?

In Ubuntu 12.04, I have jdk7 from sun/oracle installed. When locate jni.h, it prints multiple locations

/usr/lib/jvm/java-6-openjdk-amd64/include/jni.h /usr/lib/jvm/jdk1.7.0_07/include/jni.h ... 

In the header file generated by JDK, there is include <jni.h>, and currently it complains

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

In my Makefile, there is no specification of locations where jni.h is. And I am asking if possible to configure certain system parameter to make path of jni.h (say, /usr/lib/jvm/jdk1.7.0_07/include/jni.h) to be known when being compiled.

like image 854
Richard Avatar asked Jan 25 '13 20:01

Richard


People also ask

What is JNI h file?

jni. h is a C/C++ header file included with the JDK that maps Java types to their native counterparts. javah automatically includes this file in the application header files.


2 Answers

You have to tell your compiler where is the include directory. Something like this:

gcc -I/usr/lib/jvm/jdk1.7.0_07/include 

But it depends on your makefile.

like image 65
jdb Avatar answered Oct 02 '22 13:10

jdb


It needs both jni.h and jni_md.h files, Try this

gcc -I/usr/lib/jvm/jdk1.7.0_07/include \   -I/usr/lib/jvm/jdk1.7.0_07/include/linux filename.c 

This will include both the broad JNI files and the ones necessary for linux

like image 27
yogesh singh Avatar answered Oct 02 '22 12:10

yogesh singh