Results 1 to 6 of 6
  1. #1
    bapu is offline Member
    Join Date
    Nov 2010
    Posts
    3
    Rep Power
    0

    Smile call win32 api from java

    how can i call win32 API from java using JNI?
    i don't want to use other commercial packages to download and install.
    it should be done only by jvm and i have vc++ installed.
    plz submit any code and steps required to do so?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    This is too involved and general a question to be simply answered in the forum or solved with a code snippet. I strongly urge you to google for JNI tutorials and start studying. Then later if you get stuck at a specific step and have an answerable question, please come on back and we'll try to help you.

    Much luck and welcome to the forum.

  3. #3
    bapu is offline Member
    Join Date
    Nov 2010
    Posts
    3
    Rep Power
    0

    Default

    i tried this :

    public class NewMain
    {
    static{System.load("C:\\WINDOWS\\system32\\kernel3 2.dll");}
    native private static short GetSystemDefaultLangID();

    public static void main(String ss[])
    {
    System.out.print(GetSystemDefaultLangID());
    }

    }

    but trows an exception of java.lang.UnsatisfiedLinkError.

    why?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Come on now get serious. You can't do JNI without first reading how to do it. Trial and error will not work here.

  5. #5
    bapu is offline Member
    Join Date
    Nov 2010
    Posts
    3
    Rep Power
    0

    Smile call win32 api from java

    i have searched a lot on google but provides tutorials on creating c/c++ file and use it from java.But not found any help on calling apis from existing dll.
    As you know please give me the link for that.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    That's just it -- you don't call the link directly in your Java program. It needs to be wrapped first in a C or CPP program that conforms with JNI specifications and with the header file created by the javah program. This is all spelled out in most any JNI tutorial. You can find links to them in the Wikipedia article on JNI, but the first one to read is the Sun/Oracle tutorial: Java Native Interface: Programmer's Guide and Specification

    But this too is linked to in the Wikipedia article.

    Another option is JNA though and you may wish to explore this too: JNA Official Site
    Last edited by Fubarable; 11-01-2010 at 10:44 PM. Reason: added link to JNA official site

Similar Threads

  1. how to call Java Bean Ireport frm Java application
    By Prashant.surwade in forum Advanced Java
    Replies: 8
    Last Post: 05-06-2012, 03:39 PM
  2. Problem with running eclipse-jee-helios-win32-x86_64
    By rohit_mali55@yahoo.in in forum Eclipse
    Replies: 2
    Last Post: 09-09-2010, 03:48 PM
  3. call by value and call by reference in java
    By sandeepsai39 in forum New To Java
    Replies: 7
    Last Post: 08-12-2010, 11:03 AM
  4. JFileChooser and Native OpenFile Dialog(win32)
    By paluee in forum AWT / Swing
    Replies: 2
    Last Post: 03-25-2009, 10:25 PM
  5. Accessing RS 232, serial (com) port on windows (win32)
    By sunnyalex in forum New To Java
    Replies: 1
    Last Post: 10-15-2008, 05:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •