This week's book giveaway is in the Testing forum. We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line! See this thread for details.
I am working on converting an old project written in Visual J++ to pure java. It has direct call to Windows SDK API, such as: Kernel32.createProcess() User32.RegisterWindowMessage() User32.PostMessage()
I am wondering in pure Java, is it possible to achieve this? If so, how do I do that. Any pointer to information would be greatly appreciate. (BTW, my java application would only run on Windows platform.)
Ugh. Sounds like a fun project. You can use JNI (Java Native Interface) if you are sure that you will always be running on Windows. On the other hand, you could figure out what those calls are actually doing and try to duplicate them in pure Java.
CreateProcess you can certainly emulate in pure Java using the Runtime.exec() methods. If RegisterWindowMessage() and PostMessage() are being used for interprocess communication, then you're out of luck -- JNI is your only route. I think there are several commercial products that provide access to the whole Win32 API for Java via JNI.
But it's actually possible that RegisterWindowMessage() and PostMessage() are just being used within the single application, and if that's the case, then they can be replaced with plain old AWT/Swing event handling.
Thank you all for your reply. User32.RegisterWindowMessage() and User32.PostMessage() are used for communication with another application written in Visual C++. I guess I would try JNI first, the library needed are kernel32.lib and user32.lib, which are shipped with Windows. If that does not work, I would investigate the commercial package.
Just want to put a closure on this topic. I ended up using Coroutine component from NevaObject in order to make call to Wind32 API to send message to the other application. The other application is actually a DDE server written in C++. I did not have to rewrite the DDE server at all. I also investigated the option of rewriting DDE server in pure Java. I checked out the DDE server component from NevaObject. From their online forum, looks like it is a bit heavy weight, uses quite some resource. And our old C DDE server utilizes Windows message mechanism for DDE function, is quite light-weight. So, now the whole application is still a combination of Java and C and a little third party component. And it works great. Thanks for everybody's input!
I claim this furniture in the name of The Ottoman Empire! You can keep this tiny ad: