Link to home
Start Free TrialLog in
Avatar of WalterRautenbach
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.UnsatisfiedLinkError: ShowMsgBox.MessageBox(ILjava/lang/String;Ljava/lang/String;I)I
      at ShowMsgBox.MessageBox(Native Method)
      at ShowMsgBox.main(ShowMsgBox.java:5)
>Exit code: 1
ASKER CERTIFIED SOLUTION
Avatar of gatorvip
gatorvip
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mayank S
Try putting it in your JDK's bin directory or just put it into your Windows\System32 directory.
Avatar of WalterRautenbach
WalterRautenbach

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
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
>> it is a simple program which calls the systems USER32.DLL so the dll is in a class path.

You mean PATH, not Classpath?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial