Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jni.h: No such file or directory

I have been following this tutorial, and at step 5, I am getting the following output from GCC:

    HelloWorld.c:1:17: error: jni.h: No such file or directory     In file included from HelloWorld.c:3:     HelloWorld.h:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’     HelloWorld.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’ 

I know that he include directories vary from system to system, so I tried to adapt the command accordingly, but I cannot seem to find the correct directory on my system. I am using Ubuntu 10.04LTS.

like image 278
Jack H Avatar asked Jul 24 '11 00:07

Jack H


People also ask

What is JNI h file?

JNI Components 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. JNI data type mapping in variables. Code: boolean jboolean.


2 Answers

Open up a terminal and type:

locate jni.h 

That should tell you where every file called jni.h is on your system. I am on ubuntu 11.04, and it's located at:

/usr/lib/jvm/java-6-openjdk/include/jni.h /usr/lib/jvm/java-6-sun-1.6.0.26/include/jni.h 

You may also need to get it from the repos:

sudo apt-get install openjdk-6-jdk  

should do the trick if you don't have it installed.

like image 94
Leif Andersen Avatar answered Sep 19 '22 07:09

Leif Andersen


jni.h lives with JDK. For me it is: jdk1.6.0_25/include/.

And by default, I don't think Ubuntu would have JDK with development libraries, so download latest JDK version from Oracle and install it somewhere.

Or you can install openjdk as @Leif suggested if it works on 10.04 LTS. Although, I personally, prefer the one from Sun/Oracle.

like image 21
Alex Gitelman Avatar answered Sep 22 '22 07:09

Alex Gitelman