Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

java.lang.UnsatisfiedLinkError: no hello in java.library.path

843829Apr 14 2004 — edited Jul 2 2004
Hello
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...



Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 30 2004
Added on Apr 14 2004
9 comments
1,472 views