6.2. A Simple Startup Example

Now, let's develop this simple example program using the JNI tool. We use the steps in Figure 6-3 to develop this example.

6.2.1. Create a Java Source File that Calls a Native Library

Open the NotePad editor and enter the Java source code shown in Figure 6-4. Click the File menu item from the NotePad editor, and click Save to save this file as “TestPrintf.java” to a directory; in our case, to the C:\Java folder.

Figure 6-4.
						/*******************************************************************
						* NAME      : Test code for the JNI program for printf in C.
						* DATE      : 5/27/2002
						*******************************************************************/
						public class TestPrintf
						{
						public static native void greet();
						static
						{
						System.loadLibrary("JNIPrintf"); ...

Get Applications Interface Programming Using Multiple Languages: A Windows® Programmer's Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.