Debugging Java calling COBOL and accessing COBOL working-storage (separate projects)

You need to run through the Java calling COBOL and accessing COBOL working-storage (separate projects) example before attempting this, as it creates the projects required (JCallShare and CCallShare) to complete these steps.

The attach to process technique used here can also be applied to the other examples in this section that deal with separate projects.

  1. Set two breakpoints in the Java program (Demo4.java):
    1. From within JCallShare, open Demo4.java in the editor.
    2. Set breakpoints on line 9 (the line that reads System.out.println("--Java--");) and line 37 (the line that reads progs.demo4();).
  2. Set a breakpoint in the first COBOL program (demo4.cbl):
    1. From within CCallShare, open demo4.cbl in the editor.
    2. Set a breakpoint on line 15 (the line that reads display "--In COBOL Program demo4--").
  3. Click Down arrow to the right of Debug configurations (Debug) and select the run configuration that you used to run Demo4.java in the previous example.
  4. If you are prompted to switch to the Debug perspective, click Switch.

    The Debug perspective is displayed, and the debugger runs until it hits the first breakpoint set in Demo4.java.

  5. Use the usual debug commands to step into, step over, etc... until you reach the next breakpoint (line 37 - progs.demo4();).
    Shortcut: Click Resume debugging(Resume) to jump to the breakpoint.

    At this point, only Demo4.java is on the debug stack. We need to also attach demo4.cbl, so that we can also step though that code.

  6. Attach demo4.cbl to the running Java debug process:
    1. Click Down arrow to the right of Debug configurations (Debug) and select Debug Configurations.

      The Debug Configurations dialog box is displayed.

    2. In the left-hand pane, double-click COBOL Attach to Process.

      A new configuration is displayed in the right-hand pane.

    3. In the Name field, enter a name for the configuration.
    4. Click Browse to the right of the COBOL Project field, and then select CCallShare.
    5. Click Debug.

      The Select Process dialog box is displayed.

    6. Select the Java process currently being debugged, and then click OK.
      Tip: The process is named javaw.exe; if you have more than one entry, match the process ID with the one displayed in the debug stack.

      The demo4.cbl program is added to the stack.

  7. Within the debug stack, ensure that the Demo4.main entry is selected, and then click Resume debugging(Resume) again.

    Debugging flow continues to demo4.cbl and stops on the breakpoint set previously.

  8. Continue to debug as normal.
This demonstrates how you can debug through both the Java code and the COBOL code.