Calling COBOL from a Java Command Line

You can call COBOL from a Java command line and without having to write a Java program. This is done by specifying a Java command line that calls the ACUCOBOL-GT Java Native Interface "CVM.jar", specifies the path to the ACUCOBOL-GT runtime, and passes an ACUCOBOL-GT runtime command.


java -cp path-to-CVM.jar com.acucorp.acucobolgt.runcbl 
--acugt path-to-AcuGT-runtime [java-options] 
runtime-command-line path-to-cobol-program 

Syntax Definitions and Parameters

java -cp path-to-CVM.jar com.acucorp.acucobolgt.runcbl Required syntax for calling the AcuGT CVM
- -acugt Required parameter that brings in the AcuGT runtime.
path-to-AcuGt-runtime Required syntax that specifies the location of the AcuGT runtime.
java-options Optional parameters described in the next table.
runtime-command-line Any valid runtime command line options. See Runtime Options for details on runtime command lines.
cobol-program The name of the COBOL program to run.
java-options Description
- -log Creates a log
- -logfile Creates a log file
- -verbose Creates detailed log
- -lib

There is a default list of libraries that automatically get loaded for both UNIX and Windows. On most systems the Java runtime will determine the correct list to load. The default library lists on UNIX is:


The default list on Windows is: acme,atermmgr,avision5,libexpat,axml32,wrun32

On some systems such as HP-UX it may be required to specify these files manully by using the --lib option. The library names must be separated by either commas or semi-colons.The library names should also be specified in the order given above.

In most UNIX and Windows cases, it should not be necessary to use this option.

- -libtext Used to specify the library name's file extension. This option may be needed on certain systems such as HP-UX. In most UNIX and Windows cases, it should not be necessary to use this option.

Syntax Example

The following is a sample Java command line for calling a COBOL program named "tour".

Java -cp "C:\Program Files\Micro 
com.acucorp.acucobolgt.runcbl --acugt "C:\Program Files\Micro 
Focus\Acucbl900\AcuGT\bin" -dle xxx "C:\Program Files\Micro