Previous Topic Next topic Print topic


Java Calling JVM COBOL

In order to call JVM COBOL from Java, you need to add the JVM COBOL project to the build path of the Java project and to import any COBOL classes you want to use into your Java sources.

This is an outline of the steps to enable calling JVM COBOL from Java:

  1. In your Eclipse workspace, create a JVM COBOL project for your COBOL program.
  2. In your Eclipse workspace, create a Java project for the calling Java program.
  3. In the Java project, add the JVM COBOL project to the project's Java build path.
  4. Add mfcobol.jar and the JVM COBOL Runtime, mfcobolrts.jar to the project's classpath.

    This ensures proper interoperation of Java code with COBOL types which are not directly mapped to JVM types such as COBOL group items or COBOL numeric types which are longer than four bytes.

  5. In the Java source code, add an import statement to import the COBOL class you want to use or the entire package into your Java source file as follows:
    import com.microfocus.cobol.MyClass

    or

    import com.microfocus.cobol.*
    Note: We recommend that you use the RunUnit class for multi-user environments. See com.microfocus.cobol.runtimeservices for more information.
Previous Topic Next topic Print topic