Accessing Windows Native API using Java

I was looking at alternatives besides JNI(Java Native Interface) to accessing Windows native API.

I came across two open source projects Java Native Access( will be referred to as JNA) and JNative. I initially started with JNA and also came across a useful tutorial for the same. Unfortunately I tried developing access to other Windows API and came across issues such as procedure not found. I was unable to find a suitable way for mapping the native data types like LPTSTR or LPDWORD.

After spending some frustrating hours I gave up and started with JNative. Using JNative is a breeze especially since
the project provides sample implementations for standard Windows DLLs like kernel32, GDI32, User32, Advapi32 etc.
These implemenation classes act as references for custom implementations. All in all I am for JNative project for abstracting Java Native access.

Advertisements

One thought on “Accessing Windows Native API using Java

  1. This is moot to you now given the age of this post, but for future readers, LPTSTR and LPDWORD can be mapped to char[] and com.sun.jna.ptr.IntByReference, respectively, in JNA.

    Both libraries are pretty slick, but my vote would go towards JNA since it is much more lightweight on reproducing structs and making the libraries interfaces is not only simple but is more conducive to reflecting the underlying API. Just my 2ยข. Oh, and in my tests, JNA is significantly faster, too…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s