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);
} 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)
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.