Rational Developer for System z
PL/I for Windows, Version 8.0, Programming Guide

Step 1: Writing the Java Program

Declare the Native Method

All methods, whether Java methods or native methods, must be declared within a Java class. The only difference in the declaration of a Java method and a native method is the keyword native. The native keyword tells Java that the implementation of this method will be found in a native library that will be loaded during the execution of the program. The declaration of our native method looks like this:

public native void callToPLI();

In the above statement, the void means that there is no return value expected from this native method call. The empty parentheses in the method name callToPLI( ), means that there are no parameters being passed on the call to the native method.

Load the Native Library

A step that loads the native library must be included so the native library will be loaded at execution time. The Java statement that loads the native library looks like this:

 static {
   System.loadLibrary("hiFromPLI");
 }

In the above statement, the Java System method System.loadLibrary(...) is called to find and load the dynamic link library (DLL). The PL/I dynamic link library, hiFromPLI.dll, will be created during the step that compiles and links the PL/I program.

Write the Java Main Method

The callingPLI class also includes a main method to instantiate the class and call the native method. The main method instantiates callingPLI and calls the callToPLI() native method.

The complete definition of the callingPLI class, including all the points addressed above in this section, looks like this:

 public class callingPLI {
   public native void callToPLI();
   static {
      System.loadLibrary("hiFromPLI");
   }
   public static void main(String[] argv) {
      callingPLI callPLI = new callingPLI();
      callPLI.callToPLI();
      System.out.println("And Hello from Java, too!");
   }
 }
Rational Developer for System z
PL/I for Windows, Version 8.0, Programming Guide