This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Link Error Which is Never Satisfied Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
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 ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Link Error Which is Never Satisfied
 
Similar Threads
javac: no classpath found
how to include JNI.h(java native interface)
JNI What is it, and can I use it
How to Connect C using (JNI) java native Interface??
Problem in compiling C file with JNI