WalterRautenbach
asked on
DLL HELP!!!
Hi there.
Im struggling with a project that includes a dll, so i got an example off the net that shud run quite simply but it does not, here is the source code and the error.
I dont know if it could be my system configeration?
thanx.
class ShowMsgBox
{
public static void main(String args[])
{
MessageBox(0, "It worked!",
"This is a message box from Java", 0);
}
/** @dll.import("USER32") */
private static native int MessageBox(
int hwnd
, String text
, String title
, int style
);
}
ERROR:
>java ShowMsgBox
Exception in thread "main" java.lang.UnsatisfiedLinkE rror: ShowMsgBox.MessageBox(ILja va/lang/St ring;Ljava /lang/Stri ng;I)I
at ShowMsgBox.MessageBox(Nati ve Method)
at ShowMsgBox.main(ShowMsgBox .java:5)
>Exit code: 1
Im struggling with a project that includes a dll, so i got an example off the net that shud run quite simply but it does not, here is the source code and the error.
I dont know if it could be my system configeration?
thanx.
class ShowMsgBox
{
public static void main(String args[])
{
MessageBox(0, "It worked!",
"This is a message box from Java", 0);
}
/** @dll.import("USER32") */
private static native int MessageBox(
int hwnd
, String text
, String title
, int style
);
}
ERROR:
>java ShowMsgBox
Exception in thread "main" java.lang.UnsatisfiedLinkE
at ShowMsgBox.MessageBox(Nati
at ShowMsgBox.main(ShowMsgBox
>Exit code: 1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try putting it in your JDK's bin directory or just put it into your Windows\System32 directory.
ASKER
it is a simple program which calls the systems USER32.DLL so the dll is in a class path.
Does any one know how the /** @dll.import("USER32") */ statment is used.
im using that statment to try avoid creating an new C++ file to connect to a DLL.
Thanx
Does any one know how the /** @dll.import("USER32") */ statment is used.
im using that statment to try avoid creating an new C++ file to connect to a DLL.
Thanx
Use System.load("user32");
See http://forum.java.sun.com/thread.jspa?threadID=596284&messageID=3154658 (last post currently) for a very nice example of cross-platform library load
See http://forum.java.sun.com/thread.jspa?threadID=596284&messageID=3154658 (last post currently) for a very nice example of cross-platform library load
>> it is a simple program which calls the systems USER32.DLL so the dll is in a class path.
You mean PATH, not Classpath?
You mean PATH, not Classpath?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.