Example: Prepare the example source code

Before moving the IBM® i5/OS™ PASE native method for Java™ example to your iSeries™ server, you need to compile the source code, create a C include file, and create a shared library object.

The example includes the following C and Java source files:

You use the compiled Java .class file to create a C include file, PaseExample1.h, which contains a function prototype for the getStringNative method contained in the C source code.

To prepare the example source code on your AIX® workstation, complete the following steps:

  1. Use the following command to compile the Java source code:
         javac PaseExample1.java
  2. Use the following command to create a C include file that contains the native method prototypes:
         javah -jni PaseExample
    The new C include file (PaseExample1.h) contains a function prototype for the getStringNative method. The example C source code (PaseExample1.c) already includes the information you would copy and modify from the C include file to use the getStringNative method. For more information about using JNI, see the Java Native Interface tutorial on the Sun Web site.
  3. Use the following command to compile the C source code and create a shared library object.
         xlc -G -I/usr/local/java/J1.3.0/include PaseExample1.c -o libPaseExample1.so
    The new shared library object file (libPaseExample1.so) contains the native method library "PaseExample1" that the example uses.

    Note: You may need to change the -I option to point to the directory that contains the correct Java native method include files (for example, jni.h) for your AIX system.

For more information about the IBM i5/OS PASE native method for Java example, see the following topics: