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
Java

Avatar of undefined
Last Comment
Mayank S
ASKER CERTIFIED SOLUTION
Avatar of gatorvip
gatorvip
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Mayank S
Mayank S
Flag of India image

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
Avatar of gatorvip
gatorvip
Flag of United States of America image

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
Avatar of Mayank S
Mayank S
Flag of India image

>> 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
Avatar of Mayank S
Mayank S
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Java
Java

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.

102K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo