aspose file tools
The moose likes Java in General and the fly likes Link Error Which is Never Satisfied Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Link Error Which is Never Satisfied" Watch "Link Error Which is Never Satisfied" New topic
Author

Link Error Which is Never Satisfied

kundan vyas
Greenhorn

Joined: Jun 22, 2000
Posts: 5
Hi Guys,
Even I am facing a similar problem.I am trying to call a function from kernel32.dll .
My Code
public class HelloWorld {
public native boolean Beep(long freq,long duration);

static {
try{
System.out.println(System.getProperty("java.library.path"));
System.loadLibrary("kernel32");
}
finally
{
System.out.println("arg debug: after loadLibrary");
}

}
public static void main(String[] args) {
HelloWorld obj=new HelloWorld();
boolean flag=obj.Beep(500L,500L);
}
}
I am executing the following steps
1)javac HelloWorld.java
2)javah -jni HelloWorld
3)java HelloWorld
I am getting the following error
java.lang.UnsatisfiedLinkError: Beep at
at HelloWorld.Beep(Native Method)
at HelloWorld.main(HelloWorld.java:20)
I ve also tried the System.load("c:/windows/system/kernel32.dll") method. The library seems to be getting loaded either ways. I think HelloWorld.h header file has some problem.
Do I need to put my HelloWorld.h file in the include folder of JDK. Kindly check this problem.
Kundan
(kundanvyas@yahoo.com)


kundanvyas@yahoo.com
Servin Park
Greenhorn

Joined: May 10, 2002
Posts: 26
As far as I know, you have to build HelloWorld.dll from HelloWorld.h created by executing javah -jni HelloWorld. You can't just use kernel32.dll. After building HelloWorld.dll, do either System.loadLibrary("HelloWorld") or System.load("C:/path/to/your/HelloWorld.dll");. Refer to Sun's JNI overview. It gives ample explanation on how to program JNI.
[ June 27, 2002: Message edited by: Servin Park ]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Link Error Which is Never Satisfied
 
Similar Threads
JNI What is it, and can I use it
Problem in compiling C file with JNI
How to Connect C using (JNI) java native Interface??
how to include JNI.h(java native interface)
javac: no classpath found