Java
--
Questions
--
Followers
Top Experts
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
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
ASKER CERTIFIED SOLUTION
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Try putting it in your JDK's bin directory or just put it into your Windows\System32 directory.
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






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
>> 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?
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Java
--
Questions
--
Followers
Top Experts
Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.