Invoking the call stub generator from a command line
We can run the COBOL call stub generator from a command line.
Create a Rational Application Developer project for the code that is generated by the COBOL call stub generator.
Create a call stub generator configuration file. Ensure that the settings for the EclipseHome, WorkSpace, and EclipseProjectName required properties are correct.
Check the PROCEDURE statement for the COBOL source file.
To run the COBOL call stub generator from a command line, you must run a command that specifies values for the configFile and callStubPackage required parameters. You also can specify values for optional parameters in the command.
The command that runs the COBOL call stub generator must use the following syntax:
java -jar COBOLCallStubGenerator.jar {input cobol file} -configFile configuration_file_name -callStubPackage package_name [-callStubClass class_name] [-cobolModule COBOL_module] [-workSpace path_name] [-eclipseProjectName project_name] [-build build_string] [-mockPackage package_name] [-mockClass class_name] [-v | -verbose] [-? | -h]
parameters to run the COBOL call stub generator. Command
Name Default value Required or Optional Description configFile
Required Name of the call stub generator configuration file. callStubPackage
Required Package name, and the file path of generated file, to use for the generated call stub. callStubClass COBOL PROGRAM-ID Optional Class name to use for the generated call stub. cobolModule COBOL PROGRAM-ID Optional Name of the COBOL module or DLL file containing the COBOL program. workSpace
Optional Fully qualified path to the root directory of the Rational Application Developer or Eclipse workspace to be used to create the Java data binding class. Any value specified for workSpace overrides the WorkSpace value in the call stub generator configuration file, which is identified by the configFile value.
eclipseProjectName
Optional Name of the project in the Rational Application Developer or Eclipse workspace that provides the home for the generated Java class. The project must exist before running the call stub generator.
Any value specified for eclipseProjectName overrides the EclipseProjectName value in the call stub generator configuration file, which is identified by the configFile value.
build Unknown Build Optional User-assigned build identifier. mockPackage
Optional Name of the package for the mock class. mockClass
Optional Name of the class to use for the mock test harness.
- Create a script that runs the call stub generator.
- Ensure that a Rational Application Developer session is not currently active for the workspace.
- Run the script.
For example, run the following command to run the Sample01.cbl script. The configuration file is named csg.properties and the stub package is named my.pkg.
$ java -jar lib/COBOLCallStubGenerator.jar script_path/Sample01.cbl -configFile csg.properties -callStubPackage my.pkg
Results
The command runs the call stub generator. If the command is successful, the call stub generator creates a COBOL call stub Java class.
When running the command, the call stub generator creates a temporary Ant build file, system_temp_directory/CSG.temp.xml, and then runs the file in a headless Eclipse session. The temporary file is deleted after the command runs.
The Java data binding classes for the COBOL parameters and return value are generated by the J2C data binding tool, which is part of the Java EE Connector tools of IBM Rational Application Developer for WebSphere Software, Version 7.5 or later. The call stub generator and the J2C data binding tool run in the headless Eclipse session, which is launched as a separate Java process.
The headless invocation of Eclipse attempts to obtain a workspace lock before running the Ant build file. If a Rational Application Developer session is currently active for the workspace, Eclipse cannot obtain a workspace lock and the command fails.
What to do next
Use the generated COBOL call stub Java class.
Related tasks
Generating COBOL call stubs Create a call stub generator configuration file