I\'m using Ubuntu 10.10
So that\'s what I did.
Hello.java:
class Hello {
public native void sayHello();
This complains about the C++ symbols not being available. I seem to remember, when I use to do JNI stuff all of the time that there were problems linking in C++ libraries and we always stuck to plain old C
If you change your code so that it's standard C (and rename the file):
#include
#include "Hello.h"
#include
JNIEXPORT void JNICALL Java_Hello_sayHello (JNIEnv *env, jobject obj) {
printf("Hello World");
return;
}
And compile it
gcc -I/usr/lib/jvm/java-6-openjdk/include -o libhellolib.so -shared Hello.c
It works
java -Djava.library.path=`pwd` Hello
Hello World