Java native interface problem

Discussion in 'Java' started by Kristian Karl, Sep 18, 2004.

  1. Hi,

    Why does not the code below work...
    I'm running int with j2re1.4.2_05, on a Windows 2000 box.

    The output is:
    Library loaded
    java.lang.UnsatisfiedLinkError: MessageBoxA



    public class ShowMsgBox extends Object {

    static {
    System.load("C:/WINNT/system32/USER32.DLL");
    }

    public static void main(String[] args) {
    try
    {
    ShowMsgBox msg = new ShowMsgBox();
    System.out.println( "Library loaded" );
    msg.MessageBoxA( 0,
    "Created by the MessageBox() Win32 func",
    "Thinking in Java", 0);
    }
    catch (UnsatisfiedLinkError e)
    {
    System.out.println( e );
    }
    }
    private native int MessageBoxA(int hwndOwner, String text,
    String title, int fuStyle);
    }

    /Regards Kristian
    Kristian Karl, Sep 18, 2004
    #1
    1. Advertising

  2. (Kristian Karl) writes:

    > Why does not the code below work...


    Because Java's JNI does not use COM methods directly.

    > java.lang.UnsatisfiedLinkError: MessageBoxA


    JNI maps a Java native method to a C method with a particular syntax.

    > private native int MessageBoxA(int hwndOwner, String text,
    > String title, int fuStyle);


    Read this:

    http://java.sun.com/j2se/1.4.2/docs/guide/jni/index.html
    Tor Iver Wilhelmsen, Sep 19, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephen Kellett

    Java Native Interface problems

    Stephen Kellett, Jan 27, 2004, in forum: Java
    Replies:
    9
    Views:
    771
    Stephen Kellett
    Jan 27, 2004
  2. Clemens Arth
    Replies:
    3
    Views:
    8,383
    Alf P. Steinbach
    Oct 11, 2004
  3. Replies:
    2
    Views:
    510
  4. Replies:
    13
    Views:
    6,051
  5. Replies:
    3
    Views:
    386
    Lawrence Kirby
    Feb 28, 2005
Loading...

Share This Page