Link to home
Create AccountLog in
Java

Java

--

Questions

--

Followers

Top Experts

Avatar of WalterRautenbach
WalterRautenbach

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

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
Avatar of gatorvipgatorvip🇺🇸

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of Mayank SMayank S🇮🇳

Try putting it in your JDK's bin directory or just put it into your Windows\System32 directory.

Avatar of WalterRautenbachWalterRautenbach

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 gatorvipgatorvip🇺🇸

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

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of Mayank SMayank S🇮🇳

>> 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 SMayank S🇮🇳

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Java

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.