S
stef
Hi
Please JNI experts, help me :
Under Linux rh 7.3
I try
class hello
{
static { System.loadLibrary("hello"); }
public native void printHello();
public static void main(String[] args)
{
System.out.println("Hello, world!");
}
}
ok,
$ javac hello.java
$ javah -jni hello
C side :
#include "hello.h"
#include "jni.h"
JNIEXPORT void JNICALL Java_hello_printHello( JNIEnv *env, jobject obj )
{
printf("Hello world!\n");
return;
}
then :
gcc -I ${JAVA_HOME}/include/ -I ${JAVA_HOME}/include/linux/ -o
hello.so -shared -fpic -lc hello.c
right, now
I set
export LD_LIBRARY_PATH=<path of hello.so>
and now :
$ java hello
gives
Exception in thread "main" java.lang.UnsatisfiedLinkError: no hello in
java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1491)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at hello.<clinit>(hello.java:3)
I don't understand
(Except the JNI, I can compile/run some java classes of course !!)
please help me guys...
thanx
Please JNI experts, help me :
Under Linux rh 7.3
I try
class hello
{
static { System.loadLibrary("hello"); }
public native void printHello();
public static void main(String[] args)
{
System.out.println("Hello, world!");
}
}
ok,
$ javac hello.java
$ javah -jni hello
C side :
#include "hello.h"
#include "jni.h"
JNIEXPORT void JNICALL Java_hello_printHello( JNIEnv *env, jobject obj )
{
printf("Hello world!\n");
return;
}
then :
gcc -I ${JAVA_HOME}/include/ -I ${JAVA_HOME}/include/linux/ -o
hello.so -shared -fpic -lc hello.c
right, now
I set
export LD_LIBRARY_PATH=<path of hello.so>
and now :
$ java hello
gives
Exception in thread "main" java.lang.UnsatisfiedLinkError: no hello in
java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1491)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at hello.<clinit>(hello.java:3)
I don't understand
(Except the JNI, I can compile/run some java classes of course !!)
please help me guys...
thanx