Skip to main content

Problem:

It is possible to animate COBOL when called from Java, but it is not possible to animate Java when called from COBOL, if COBOL is the main program, but it is possible to animate Java when called from COBOL if Java is the main program:

Resolution:

  Java ---> Cobol ---> Java

This is the case with any mix programming, the reason being that any of the third party debuggers do not have a similar feature to our "CBL_DEBUGBREAK" that allows you to start the debugger at any point of the execution of a COBOL program.

So if you want to animate an application where the main program is COBOL that invokes a Java class, then the only way of doing it is creating a dummy Java main program that calls the COBOL main program that has to be linked as a dll instead of an EXE in the following way:

1) create a simple Java program that calls the COBOL DLL e.g.:

    import mfcobol.*;

    class debugme

    {

        public static void main(String argv[]) throws Exception

        {

                int retcode = Integer.MIN_VALUE;

                try

                {

                  retcode=runtime.cobcall("debugme",null);

                }

                catch(Exception e)

                {

                        System.out.println("FAIL - Exception caught (" e ")")

;

                }

        }

    }

2) create the debuggable COBOL application as a DLL not a exec...

   HINT: use a call to CBL_DEBUGBREAK to invoke the COBOL debugger

         or compile the interested program with INITCALL"CBL_DEBUGBREAK"

3) invoke your java debugger on the first Java program... when COBOL

   hits the program or statement you are interested in debugging the

   runtime will ask you if you want to debug it...

Old KB# 6851