John
John

Reputation: 5287

Cannot find jni.h

I am trying to setup a JNI demo example and got stuck at exporting a library on Windows OS.

According to this tutorial, the following command should be executed:

gcc -o libctest.so -shared -I/path/to/jdk/headers ctest.c -lc

where the /path/to/jdk/headers refers to the directory that contains jni.h.

This is how invoke the command:

gcc -o ctest.dll -shared -I/"C:/Program Files/Java/jdk1.8.0_45/include" ctest.c -lc

and the result was:

jni.h: no such file or directory.
include jni.h

I have checked out this and this, which seems to suggest pretty much what I did.

The code:

#include <jni.h>
#include <stdio.h>

JNIEXPORT void JNICALL Java_HelloWorld_helloFromC
  (JNIEnv * env, jobject jobj)
{
    printf("Hello from C!\n");
}

How do I get around this error?

Upvotes: 0

Views: 1875

Answers (1)

dan
dan

Reputation: 13262

Have you tried with:

gcc -o ctest.dll -shared -I"C:\Program Files\Java\jdk1.8.0_45\include" ctest.c -lc

Note that after -I the slash character is not there anymore and the delimiter is set to backslash (the Windows delimiter).

Upvotes: 2

Related Questions