Start of change

Step 1: Compiling user COBOL programs

This topic describes how to compile the user COBOL programs in a non-OO COBOL application that interoperates with Java™.

In general, user COBOL programs in the application can be compiled in the same way that users normally compile their user COBOL programs. The exception is that any program that contains the JAVA-CALLABLE or JAVA-SHAREABLE directives, or uses a CALL statement to make a call to a static Java method, should now consider specifying the Java interoperability option JAVAIOP, which allows you to control various aspects of a Java interoperable program.

In particular, the JAVAIOP option allows you to do the following:
  • Control where compiler generated stub files will be written to the z/OS® UNIX file system during compilation with the OUTPATH suboption. These stub programs facilitate interoperability with Java.
    Note: The z/OS UNIX directory provided to the OUTPATH suboption of JAVAIOP must exist prior to running the compiler.
  • Control whether the interoperable application will target 31-bit Java by default or 64-bit Java with the JAVA64 suboption. Note that the JAVA64 suboption is only available when compiler option LP(32) is in effect. When LP(64) is in effect, 64-bit Java is required.
  • Specify a string of Java Virtual Machine (JVM) initialization options with JVMINITOPTIONS suboption. This is only needed for applications that start on the COBOL side and only when compiling COBOL programs in the application that contain CALL statements to Java static methods, a situation that might result in COBOL needing to start the JVM at run time. Using JAVAIOP option with the JVMINITOPTIONS suboption is an alternative to setting the COBJVMINITOPTIONS environment variable at run time for the program, which is the method required by OO COBOL and also available for non-OO Java interoperability.
For the COBPROD application, the following commands build the COBOL files, instructing the compiler to send any generated stub files and Java files to the z/OS UNIX directory ${HOME}/jtoc/docs.
cob2 -c cobprod.cbl "-qjavaiop(OUTPATH('${HOME}/jtoc/docs'))"
cob2 -c addlist.cbl "-qjavaiop(OUTPATH('${HOME}/jtoc/docs'))"
Since you are compiling these programs with the default LP(32) option by default, the compiler assumes you are targeting 31-bit Java. To target 64-bit Java instead of 31-bit Java, you would simply change the compile commands to include the JAVA64 suboption of the JAVAIOP option.
cob2 -c cobprod.cbl "-qjavaiop(OUTPATH('${HOME}/jtoc/docs'),java64)"
cob2 -c addlist.cbl "-qjavaiop(OUTPATH('${HOME}/jtoc/docs'),java64)"
Note: If this application starts on the Java side, there is no need to specify the JVMINIOPTIONS suboption, since it is Java that starts the JVM.

Next step: Step 2: Running the cjbuild utility to build a DLL of Java stub programs

Related references    
JAVAIOP
Example: COBPROD application - building and running
JAVA-CALLABLE (Enterprise COBOL for z/OS Language Reference)
JAVA-SHAREABLE (Enterprise COBOL for z/OS Language Reference)


End of change