Calling a COBOL method from a Java application under IMS
You can use the object-oriented language support in Enterprise COBOL to write COBOL methods that a Java™ program can call under IMS.
About this task
When you define a COBOL class and compile it using Enterprise COBOL, the compiler generates a Java class definition with native methods and the object code that implements those native methods. You can then create an instance and invoke the methods of this class from a Java program that runs in a Java dependent region, just as you would use any other class.
For example, you can define a COBOL class that uses the appropriate DL/I calls to access an IMS database. To make the implementation of this class available to a Java program, do the following steps:
Procedure
- Compile the COBOL class using Enterprise COBOL. The compiler generates a Java source file (.java) that contains the class definition, and an object module (.o) that contains the implementation of the native methods.
- Compile the generated Java source
file using the Java compiler.
The Java compiler creates a class file (.class).
- Link the object code into a dynamic link library (DLL) in the z/OS® UNIX file system (.so). The directory that contains the COBOL DLLs must be listed in the LIBPATH, as specified in the IMS.PROCLIB member that is indicated by the ENVIRON= parameter of the IMS region procedure.
- Update the sharable application class path in the main JVM options member (ibm.jvm.sharable.application.class.path in the IMS.PROCLIB member that is specified by the JVMOPMAS= parameter of the IMS region procedure) to enable the JVM to access the Java class file.
Results
A Java program cannot call procedural COBOL programs directly. To reuse existing COBOL IMS code, use one of the following techniques:
- Restructure the COBOL code as a method in a COBOL class.
- Write a COBOL class definition and method that serves as a wrapper
for the existing procedural code. The wrapper code can use COBOL
CALL
statements to access procedural COBOL programs.
Compiling, linking, and running OO applications
Structuring OO applications
Wrapping procedure-oriented COBOL programs
IMS Application Programming Guide