After much delay, I finally bought a copy of JNIWrapper, which is one very cool piece of software. Basically, it’s a set of libraries that gives you access to the Win32 libraries without the need of writing your own C wrapper classes for JNI.
And it’s not just for Win32 either - COM is supported out of the box! Run their nifty swing app, select the COM library you want to use (from the list they prepopulate from your registry!), set where you want it dump the Java wrapper classes, and boom. Java COM Factory wrappers, interfaces, and concrete classes are all there, ready to go - including all those dodgy Win32 BStr classes you need when calling COM. You can even tell your COM factories to instantiate ApartmentThreaded, Multithreaded and all that other Win32 goodness that really only David Chappell understands anyway.
Best of all, the documentation and tutorial examples are first class. By the end of my first session, I had created Java stubs for the COM object I was into, and made a few calls to see all was working as planned. Any that’s with pretty vanilla Win32 skills on my end.
If you’re not into COM, and need to call straight Win32 stuff, types are provided for all the standard Window enums, and you can roll your own if you have to. The exception handling is awesome, Win32 faults get converted to Java exceptions, getLastError()
works, and it’s all memory-safe to boot.
They even ship with a “WinPack” library that puts a Java wrapper round a ton of common Win32 things you’re likely to want to do (like the Registry, Filesystem Watches, Window operations like transparency, Tray icons and all that nativey stuff). But if what you want is not in there already, it’s pretty trivial to call any Win32 routine if you know the signature.
If Win32 is not your bag, it ships with versions for Linux/Mac too! I am loving the power, and at $US120 for a bundle of both Win32 and Unix libraries, it’s an absolute steal - and we don’t have to mix up any C code in our project! Great work, guys!