Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Using JNA to access export native classes

  1. #1
    Junior Member
    Join Date
    May 2011
    Thanked 0 Times in 0 Posts

    Default Using JNA to access export native classes

    Hi everyone,

    Currently I am working on java project which uses methods and classes present inside a DLL. Suppose I have such a method inside the DLL(named MyDLL.dll):

    Method inside my DLL code
    extern "C" __declspec(dllexport) int myMethod();

    corresponding JNA implementation
    import com.sun.jna.Library;
    import com.sun.jna.Native;
    import com.sun.jna.Platform;
    /** Simple example of native library declaration and usage. */
    public class HelloWorld {
        public interface CLibrary extends Library {
            CLibrary INSTANCE = (CLibrary) Native.loadLibrary("MyDLL", CLibrary.class);
            int myMethod();
    public static void main(String[] args) {
    String libPath = "path to MyDLL.dll";
    System.setProperty("jna.library.path", libPath);
    int RetVar = CLibrary.INSTANCE.myMethod();
    }          ////main function ends
    }                ////class ends

    So, my doubt is that like the function present inside the DLL, I have also got a class inside the DLL which needs to be exported:

    Class inside my DLL code
    extern "C" __declspec(dllexport) Class myClass
    //////code inside class

    So, now the question is how I am gonna use this native class inside my java code like i did for the native method?

    Thanking in advance,

    With regards,
    Satya Prakash.

  2. #2
    Junior Member
    Join Date
    May 2011
    Thanked 0 Times in 0 Posts

    Default Re: Using JNA to access export native classes

    Hello everybody,

    Someone, please reply to this query. It's kinda urgent. Sorry, for the urgency, but atleast tell if it is possible or not? I am using JNA(Java Native Access) package for accessing native methods. Is it possible by the use of any other package like JNI or some other package?

    Waiting for a reply,

    With regards,
    Satya Prakash.
    Last edited by sattu; May 9th, 2011 at 06:22 AM.

Similar Threads

  1. calling native c code from java using JNI
    By ashok_jeev in forum Java Native Interface
    Replies: 3
    Last Post: November 20th, 2012, 05:28 AM
  2. Resize a window without native decorators
    By supertreta in forum AWT / Java Swing
    Replies: 0
    Last Post: January 11th, 2011, 02:06 PM
  3. Netbeans and inner classes/variable access
    By jmorr212 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 17th, 2010, 10:22 PM
  4. Default Access (package access) confusion
    By gauravrajbehl in forum Java Theory & Questions
    Replies: 1
    Last Post: November 18th, 2009, 04:11 AM
  5. Export to excel
    By ebosysindia in forum File I/O & Other I/O Streams
    Replies: 7
    Last Post: May 14th, 2009, 06:25 AM