Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JNI: java.lang.UnsatisfiedLinkError

Status
Not open for further replies.

cadbilbao

Programmer
Apr 9, 2001
233
0
0
ES
Hello:

I get this error message when calling 'Main.class':
Exception in thread "main" java.lang.UnsatisfiedLinkError: displayMessage
at HelloWorld.displayMessage(Native Method)
at Main.main(Main.java:6)

class Main
{
public static void main(String[] args)
{
HelloWorld hello = new HelloWorld();
hello.displayMessage();
}
}

And HelloWorld.java:
class HelloWorld
{
public native void displayMessage();
static
{
System.loadLibrary("HelloWorldImp");
}
}

What am I doing wrong?
 
It means JVM can't find your library, HelloWorldImp.dll on windows, HelloWorldImp.so on Solaris, etc.
 
>It means JVM can't find your library...

not necessarily. This unsatisfiedLinkError could mean that you forget to compile it correctly.

cadbilbao,
is your class located in a package? If it is in package, i.e.

package mypackage.test;


then when you create the header file(by running javah) for,

i.e. Myclass.java located inside test directory, make sure to compile it like this:-


javah mypackage\test\Myclass.java

starting from OUTSIDE of your mypackage directory. So if your dir structure is:-

D:\javapp\mypackage\test

then at the command prompt,navigate to D:\javapp directory
and type in javah command starting from there.


that should fix the error






~za~
You can't bring back a dead thread!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top