Use the cob2_j command to link OO COBOL applications. When you link using cob2_j, thread-enabled libraries are used for linking the application.
To prepare an OO COBOL client program for execution, link the object file to create a shared library.
To prepare a COBOL class definition for execution:
For a COBOL source file Classname.cbl that contains the class definition for Classname, you would use the following commands to compile and link the components of the application:
| Command | Input | Output |
|---|---|---|
| cob2_j -c Classname.cbl | Classname.cbl | Classname.o, Classname.java |
| cob2_j -o libClassname.so -bnoentry -bM:SRE Classname.o | Classname.o | libClassname.so |
| javac Classname.java | Classname.java | Classname.class |
After you issue the cob2_j and javac commands successfully, you have the executable components for the program: the shared library libClassname.so and the class file Classname.class. All files from these commands are generated in the current working directory.
Example: compiling and linking a COBOL class definition
related tasks
Compiling programs
REPOSITORY paragraph for defining a class
Passing options to the linker
Using shared libraries
related references
cob2, cob2_j, and cob2_r options
Object-oriented syntax, and Java 5 or Java 6