PDA

Click to See Complete Forum and Search --> : using J/Direct for API


asterix299
Jan 24th, 2007, 09:46 AM
I want to get into using the win32 API with java but I can't find any good tutorials on how to use it.

I'm familiar with using the API because I've used it a lot in VB .NET... Basically what I need to know is the following:

1. Is J/Direct included in the regular sdk? If not where do I get it?
2. What do I have to import in order to use J/Direct?
3. What is the best way to convert a VB API function declaration into a Java function declaration? For example, How would I declare the FindWindow() function in Java? How does it know to look in user32.dll?
4. Any other info I may find useful.

CornedBee
Jan 24th, 2007, 11:50 AM
Java is platform independent. Trying to use the API from it is misguided.

J/Direct was created by Microsoft specifically for Visual J++, their crippled JVM. This product is no longer under development - in fact, Sun's won some case against MS so they can't develop it any further. J/Direct is not available for any other JDK.

The only way to use the WinAPI from Java is to wrap it all in JNI classes written in C or C++. Such wrappers exist in SWT, the Standard Widget Toolkit, developed by the Eclipse project. However, they are part of the internal code and not meant to be used directly. (They also wrap only the minimal subset of the API they need, so you'll probably find a lot of stuff missing.)


Bottom line: don't use the WinAPI from Java. Use Swing or SWT for windowing, and use a different language if you want API access.