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 [parameter...]

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; this should be the AcuGT\lib sub-directory of your product install directory.
Note: To successfully run the COBOL program, the AcuGT runtime license file also needs to be located; an attempt to do this is made by appending AcuGT\bin to the product install directory path specified here.
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.
parameters One or more (optional) parameters required to run the COBOL program.
Note: To pass parameters using this method, your COBOL program must define the parameters in a Linkage Section, and use the Procedure Division Using... syntax.
java-options Description
--log Creates a log
--logfile Creates a log file
--verbose Creates detailed log

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 list on UNIX is: acme, acuterm, vision, aclnt, axml, runcbl

The default list on Windows is: acme, atermmgr, avision6, expat, axml32, wrun32

Note: 64-bit versions of these libraries have a 64 suffix, where available.

On some systems such as HP-UX, it may be required to specify these files manually by using the --libs 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.acu.


Java -cp "C:\Program Files (x86)\Micro Focus\extend 10.2.0\AcuGT\bin\CVM.jar" com.acucorp.acucobolgt.runcbl --acugt "C:\Users\Public\Documents\Micro Focus\extend 10.2.0\sample\tour.acu" 


java -cp /usr/acu/10-2-0/tools/CVM.jar com.acucorp.acucobolgt.runcbl --acugt /usr/acu/10-2-0/lib tour.acu