The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Java Native Interface (Problem)

Posted by Atif Nazar Ali on December 04, 2000 at 7:18 AM

Hello
Im trying to call the MessageBox method which is defined in the USER32.dll library. The Visual J++ is running it properly but the Sun JDK is giving the problem even it is compiling it correcly Please check the following code First i am writing the output then i am wrting the code.
EXCEPTION
----------------------------------------------------------
Library Loaded
java.lang.UnsatisfiedLinkError: MessageBox
at NativeMFCMsg.MessageBox(Native Method)
at NativeMFCMsg.main(NativeMFCMsg.java:24)
Error
java.lang.UnsatisfiedLinkError: MessageBox
-------------------------------------------------------------
CODE
______________________________________________________________

import java.io.*;

public class NativeMFCMsg
{
static {
try {
System.loadLibrary("user32");
System.out.println("Library Loaded");
}
catch(Exception e)
{
e.printStackTrace();
}
}


public native int MessageBox( int hWnd,String lpText,String lpCaption,int uType );

public static void main(String[] args)
{

try {

new NativeMFCMsg().MessageBox(0,"Hello","Caption",0);

}
catch(UnsatisfiedLinkError ex)
{
ex.printStackTrace();
System.out.println("Error " + "\n" + ex.toString());
System.exit(1);
}
}

}
_________________________________________________________________

Please I am waiting Reply From You.................

Thanks In Advance.




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us