This chapter introduces J/Invoke, and walks through its features using a series of small examples.
We begin with setting up our development environment and downloading and installing J/Invoke. We then wet our feet with a quick example that calls the Win32 API from Java. The next section discusses J/Invoke features and introduces the helper classes in the com.jinvoke.win32 package that make calling the Win32 API even easier. This is followed by a tour of J/Invoke annotations, enumerations, and classes, interspersed with several small examples that highlight important features. The Data Type Conversions section spells out the general rules for converting between native types and Java types, and provides a table that can help you when writing J/Invoke declarations for Win32 functions.
Java does not have pointers, but native functions often use them. J/Invoke lets you utilize single-element Java arrays to simulate pointers. Some native functions require pointers to callback functions that they can call later. We will see how J/Invoke can let Java methods be treated as callback functions by the Win32 API. Finally, we discuss how to deploy your Java applications that use J/Invoke.