none
Cannot open include file: 'jni.h': No such file or directory

    Question

  • Hi,

    I am trying to compile a simple program with one of the headers, jni.h.

     

    #include <stdio.h>

    #include <jni.h>

    int main()

    {

    printf("Hello World");

    }

     


    But when I try to build, I get the following error -

    1>c:\test\test.cpp(2) : fatal error C1083: Cannot open include file: 'jni.h': No such file or directory

     

    This is what my include path looks like "/I[C:\Program Files\Java\jdk1.6.0_03\include]" under Project Properties-->C/C++-->General-->Additional Directories

    Kindly help...

    Thank you

    Gowri

    Wednesday, November 28, 2007 4:03 PM

Answers

  •  gowrishankar77 wrote:

     

    Thanks Carl,but I changed the path to look like this "/I C:\Program Files\Java\jdk1.6.0_03\include" and still get the same message.

     

    If you're setting the path in the project properties using the IDE, you should simply put in the path, no quotes, no /I, no nothing - just type the path into the text box in the IDE.  The VC++ project takes care of adding quotes (if needed) and appending the path to the other paths that are passed to the /I compiler option.

     

    Wednesday, November 28, 2007 8:00 PM
    Moderator

All replies

  • it should work..

    try with #include "jni.h" instead...

    you can add the path in Tools->Options->Projects and Solutions->VC++ Directories

    in the drop down select "include files" and add an entry there...

    Wednesday, November 28, 2007 5:36 PM

  • I don't know what is this #include <jni.h> file any way just have a try with #include "jni.h"

    Thanx

    Wednesday, November 28, 2007 5:44 PM
  • It looks like your include path is messed up, unless you didn't post what's really in the path- it absolutely should not have any [] in it!

     

    Contrary to other replies, using "jni.h" instead of <jni.h> won't make any difference - the only effect of using <> instead of "" on include files is that #include <file> does not search the current directory while #include "file" does.  Both forms search every directory on the include path.

     

    Wednesday, November 28, 2007 5:59 PM
    Moderator
  • NOPE...i still get the same message.What Next?

    Thanks for the suggestions though.

    Wednesday, November 28, 2007 6:02 PM
  •  

    Thanks Carl,but I changed the path to look like this "/I C:\Program Files\Java\jdk1.6.0_03\include" and still get the same message.
    Wednesday, November 28, 2007 6:05 PM
  •  gowrishankar77 wrote:

     

    Thanks Carl,but I changed the path to look like this "/I C:\Program Files\Java\jdk1.6.0_03\include" and still get the same message.


    Have a look on this Post it also contain same discussion about include file . Just check it out so that you can understand how to set path information about your include File

    Path Info

    If you have still problem please let us know

    Thanx

    Wednesday, November 28, 2007 6:41 PM
  •  gowrishankar77 wrote:

     

    Thanks Carl,but I changed the path to look like this "/I C:\Program Files\Java\jdk1.6.0_03\include" and still get the same message.

     

    If you're setting the path in the project properties using the IDE, you should simply put in the path, no quotes, no /I, no nothing - just type the path into the text box in the IDE.  The VC++ project takes care of adding quotes (if needed) and appending the path to the other paths that are passed to the /I compiler option.

     

    Wednesday, November 28, 2007 8:00 PM
    Moderator
  •  

    BOOM!Thats it!

    Thanks Carl!

    Wednesday, November 28, 2007 9:13 PM
  • Here another hint for the less experienced:

     

    if you have this problem with the jni there is one really simple way to solve it.

    1.) go to your project properties

    2.) navigate in the tree to "Configuration Properties->C/C++" then look at the first entry "Additional Include Directories"

    3.) in there enter the path: "<JDK-Version-Path>\include";"<JDK-Version-Path>\include\win32"

     

    Then the jni.h can be found, when you use:  #include <jni.h>

    Saturday, January 19, 2008 12:39 AM
  • Okay, I've done everything in this post.  I even even added the proper directories to my system Path environment variable.  I copied the jni.h file to the project's local directory.

    No matter what I do, it says 'Cannot find jni.h, file does not exist', etc.

    I'm using Visual C++ Express Edition.

    I can do all this from the command line just fine, I just want to set it up in my IDE.  Any tips?
    Saturday, April 11, 2009 5:52 PM
  • Okay, I figured it out, though still not clear on it.

    In your project properties, when you add the folders necessary to the Additional Dependencies field.  There is a checkbox that reads 'Inherent from parent or project defaults', I had to UNcheck this box for it to work.
    Saturday, April 11, 2009 5:57 PM
  • hiya I am facing the same problem, it cant find the jni.h and also the jni_md.h, I have put in the paths but nothing
    Wednesday, August 04, 2010 9:46 AM
  • hi dude

    if you are using microsoft visual studio 6.0 open the directory H:\Program Files\Microsoft Visual Studio\VC98\Include and pste the jni.h and jni_md.h files in this directory here H: is my root directory if your root directory is C: then you should open C:\Program Files\Microsoft Visual Studio\VC98\Include

    then it would work

    Wednesday, February 09, 2011 3:09 PM
  • This worked for me, thanks.
    Friday, July 05, 2013 3:43 PM