Using C$SYSTEM

Another way to invoke a Java program from COBOL is to send a Java command line to the host operating system. You can do this using ACUCOBOL-GT's C$SYSTEM library routine. This routine combines the functionality of the "SYSTEM" and "C$RUN" routines.

To call a Java program from COBOL via C$SYSTEM, you:

  1. Call the C$SYSTEM library routine as described in C$SYSTEM.
  2. Send a Java command line to C$SYSTEM to invoke the Java program. For example, to call the Java program AcuOrders, you might use this code:
    move "javaw -classpath cvm.jar;./ acuprod.AcuOrder" 
    to the-run-command.
    call "C$SYSTEM" using the-run-command.

    The C$SYSTEM routine submits the command line to the host operating system as if it were a command keyed in from the terminal.

    Note that you can call C$RUN instead of C$SYSTEM to run the Java program asynchronously, as in: call "C$RUN" using the-run-command.

  3. Pass data from the Java program to the COBOL program through a disk file or communicate through a database.

See C$SYSTEM and C$RUN for complete information on these library routines.