Miles
Miles

Reputation: 2537

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.

Upvotes: 36

Views: 43877

Answers (3)

Max Vyaznikov
Max Vyaznikov

Reputation: 4355

In Ubuntu 14.04 run:

sudo apt-get install openjdk-7-jdk openjdk-7-jre-lib

Now, you have a headers into /usr/lib/jvm/java-7-openjdk-amd64/include

For OpenJDK 6:

sudo apt-get install openjdk-6-jdk openjdk-6-jre-lib

Upvotes: 2

Alex Gitelman
Alex Gitelman

Reputation: 24732

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.

Upvotes: 7

Leif Andersen
Leif Andersen

Reputation: 22342

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.

Upvotes: 34

Related Questions