jni.h: No such file or directory

Jack H picture Jack H · Jul 24, 2011 · Viewed 36.8k times · Source

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.

Answer

Leif Andersen picture Leif Andersen · Jul 24, 2011

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.