java.lang.UnsatisfiedLinkError: no hello in java.library.path
843829Apr 14 2004 — edited Jul 2 2004Hello
I'm new in jniprogramming and im trying to get a HelloWorld program to work, it works just fine when I use a .c native code but when I try with c++ I get :
Exception in thread "main" java.lang.UnsatisfiedLinkError: no hello in java.library.path
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.<init>(Throwable.java:94)
at java.lang.Error.<init>(Error.java:50)
at java.lang.LinkageError.<init>(LinkageError.java:43)
at java.lang.UnsatisfiedLinkError.<init>(UnsatisfiedLinkError.java:42)
at java.lang.ClassLoader.loadLibrary(Compiled Code)
at java.lang.Runtime.loadLibrary0(Runtime.java:473)
at java.lang.System.loadLibrary(System.java:778)
at <Unloaded Method>
The c program and the c++ native is the same:
#include "HelloWorld.h"
#include <jni.h>
#include <stdio.h>
JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
{
printf("Hello world!\n");
return;
}
and the java code is:
class HelloWorld{
public native void displayHelloWorld();
static{
System.loadLibrary("hello");
}
public static void main (String[] args){
new HelloWorld().displayHelloWorld();
}
}
When I compile I write:
gcc -G -I/app/jsdk/1.4.2_01/include -I/app/jsdk/1.4.2_01/include/solaris HelloWorldImp.cc -o libhello.so
I have set the path with setenv LD_LIBRARY_PATH
why dosen?t it work? I would be thankful if anybody could help me...