title: JNI - "Cannot open include file: 'jni_md.h'"
body: <p>This sample program is meant to call a <code>native</code> method written in C.</p>
  
  <p><strong>Java Code</strong></p>
  
  <pre><code>class HelloWorld {
  
      private native void print();
  
      public static void main( String args[] ) {
          new HelloWorld().print();
      }
  
      static {
          System.loadLibrary("HelloWorld");
      }
  
  }
  </code></pre>
  
  <p>After writing this i compiled the program and generated a <code>JNI</code> style header file.</p>
  
  <p><strong>The header file generated is :</strong></p>
  
  <pre><code>/* DO NOT EDIT THIS FILE - it is machine generated */
  #include &lt;C:\Program Files\Java\jdk1.7.0\include\jni.h&gt;
  /* Header for class HelloWorld */
  
  #ifndef _Included_HelloWorld
  #define _Included_HelloWorld
  #ifdef __cplusplus
  extern "C" {
  #endif
  /*
   * Class:     HelloWorld
   * Method:    print
   * Signature: ()V
   */
   JNIEXPORT void JNICALL Java_HelloWorld_print
   (JNIEnv *, jobject);
  
   #ifdef __cplusplus
   }
   #endif
   #endif
  </code></pre>
  
  <p><strong>And the native method written in c</strong></p>
  
  <pre><code>#include &lt;C:\Program Files\Java\jdk1.7.0\include\jni.h&gt;
  #include &lt;C:\Program Files\Java\jdk1.7.0\include\win32\jni_md.h&gt;
  #include &lt;stdio.h&gt;
  #include "HelloWorld.h"
  
  JNIEXPORT void JNICALL Java_HelloWorld_print( JNIENv *env , jobject obj) {
      printf("Hello World!\n");
      return;
  }
  </code></pre>
  
  <p>The error I get on compiling is <code>fatal error C1083: Cannot open include file: 'jni_md.h': No such file or directory</code></p>
  
  <p>Also my compiler underlines <code>jobject obj</code> saying that <code>this class does not have storage class or specifier</code> . It underlines <code>*env</code> saying <code>expected a ')'</code>.</p>
  
  <p>Why do I get this error ?</p>