The Artima Developer Community
Sponsored Link

Java Answers Forum
Java Native Interface

2 replies on 1 page. Most recent reply: Aug 18, 2005 5:34 AM by Alex Krycek

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Sivakumar

Posts: 1
Nickname: sxvaid2
Registered: Oct, 2004

Java Native Interface Posted: Oct 20, 2004 3:16 PM
Reply to this message Reply
Advertisement
I wrote a Java Program to load user32.dll and access the methods in that dll as native methods
Please refer following code:
public class test{
static {
try{
System.loadLibrary("User32");
} catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String args[])
{
test t1=new test();
t1.MessageBeep(4);
}
public native int MessageBoxA(int i,String a,String b,String c,int j);
public native int MessageBeep(int i);
}
I complied above code, it complied with throwing an error, but at runtime I am getting a exception :
Exception in thread "main" java.lang.UnsatisfiedLinkError: MessageBeep
at test.MessageBeep(Native Method)
at test.main(test.java:13)
Instead of load Library method, I tried using load(with full path of user32.dll file), in that case also I am getting the same erro.
Can any one tell me why I am getting this exception.

Thanks in advance
Siva


Antonio

Posts: 33
Nickname: arhak
Registered: Jul, 2005

Re: Java Native Interface Posted: Jul 7, 2005 3:37 PM
Reply to this message Reply
Here is what you need to know:
http://java.sun.com/docs/books/tutorial/native1.1/index.html
If it isn't enough:
http://java.sun.com/j2se/1.4.2/docs/guide/jni/
http://java.sun.com/j2se/1.4.2/docs/guide/jni/jni-12.html

Quickly answer: user32.dll is not a JNI compliant dll
You will need to create a new dll to wrap de user32.dll so you can load that wrapper.dll in your Java code.

Alex Krycek

Posts: 1
Nickname: krycek
Registered: Aug, 2005

Re: Java Native Interface Posted: Aug 18, 2005 5:34 AM
Reply to this message Reply
Hello Antonio,
Do you have such a wrapper .dll for User32.dll? Or can you tell me how should I make such a wrapper dll? I just want to use BlockInput from this User32.dll. Maybe you can help me with this... Thanks!

Flat View: This topic has 2 replies on 1 page
Topic: free java tutorial Previous Topic   Next Topic Topic: how  to call a unix schema through java programming

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use