JWindow Demonstrates How to call Win32 APIs from Java

ID: Q177162


The information in this article applies to:
  • Microsoft SDK for Java, versions 2.0, 2.01, 2.02, 3.0, 3.1, 3.2


SUMMARY

The JWINDOW sample illustrates how to call Win32 APIs from a Java application. This sample contains a single class called JWindow which basically creates a Window by using the Win32 API CreateWindow and displays "Hello JWindow" in the client area by processing the WM_PAINT in the WndProc. This sample illustrates how to use the @dll.import directives to invoke a Win32 DLL function from Java, callbacks, and nested struct types.


MORE INFORMATION

The following files are available for download from the Microsoft Download Center. Click the file names below to download the files:

Jwindow.exe
For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center.
The JWINDOW sample contains JWindow.java, which calls the standard Win32 DLLs and illustrates how to use the @dll.import directives to invoke the DLL functions from Java.

To use J/Direct, you need to have installed version 1.02.4337 or higher of the Microsoft Compiler for Java (Jvc.exe) and the Microsoft virtual machine for Java version 2252 or later. The compiler is available with the Microsoft SDK for Java version 2.0x or later. The virtual machine, however, is no longer included with the SDK for Java in versions 3.2 and later, and must be downloaded seperately from the Developer Updates site.

When executing this Java application , if you encounter an UnsatisifiedLinkError, then check your version of the compiler. If your compiler does not support J/Direct, the Microsoft Win32 virtual machine will attempt to link native methods using the Raw Native Interface and hence will not succeed.


REFERENCES

For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, please see the following pages on the Microsoft Technical Support site:

http://support.microsoft.com/support/visualj/

http://support.microsoft.com/support/java/

Additional query words: J/Direct Win32 directives

Keywords : kbfile kbsample kbSDKJava300 kbSDKJava310 kbSDKJava320
Version : WINDOWS:2.0,2.01,2.02,3.0,3.1,3.2
Platform : WINDOWS
Issue type : kbinfo


Last Reviewed: December 16, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.