Microsoft SDK for Java

Q177162 FILE: JWindow Demonstrates How to call Win32 APIs from Java

The information in this article applies to:

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 file is available for download from the Microsoft Software Library:

JWindow.exe

http://support.microsoft.com/download/support/mslfiles/Jwindow.exe This link takes you to a site on microsoft.com

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 Microsoft® 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 (Microsoft VM) version 2252 or later. The compiler is available with the Microsoft SDK for Java version 2.0x or later. The Microsoft VM, however, is no longer included with the SDK for Java in versions 3.2 and later, and must be downloaded separately 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 VM 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 Microsoft® Visual J++® and the SDK for Java, please see the following pages on the Microsoft Technical Support site:

http://support.microsoft.com/support/visualj/ This link takes you to a site on microsoft.com

http://support.microsoft.com/support/java/ This link takes you to a site on microsoft.com

Additional query words:

J/Direct Win32 directives

© 1999 Microsoft Corporation. All rights reserved. Terms of use.