Thursday, July 26, 2007

Accessing native libraries from java

I have been toying around with a small Java project where I have had for long the need to access information about Windows (tm) controlled windows from my Java application. Also I sought after the ability able to use Window's own 'native' graphical libraries.

For long I thought I would be doomed to write my own native methods in c++/c# and use JNI to access them from Java. I haven't coded c++ for years. Thus the project stalled badly and I didn't pay attention to it for almost a year.

However yesterday I ran into some nice looking libraries that would make it much more easier for me. Both of them have kind of a similar approach where a native library can be exposed to java by creating an interface class with some native methods. The native libraries return and parameter types are automatically marshalled by the libraries too.

Of course there is some manual stuff that needs to be done, but both of them look quite nice and enable one to do quite nice things. For example have you ever seen a java window like this:

Shaped Window Demo from JNA's site

JNA (Java Native Access) seems to be more finished, has support for native libraries of Linux (x86), Mac OS X (PPC and x86), and w32+gcc and has more features than NLink. But be sure to check both!

Blog reopened!

Here and now I reopen my blog after being in the blogging void for over a half a year. Welcome back.

We had some problems with the blogging software Pebble at the open source commonity LaughingPanda which hosted my blog some time ago. We decided to drop pebble and the blogs from LaughingPanda and people started moving migrate their blogs elsewhere in the blogosphere. However I didn't seem to have the time for that then.