Declaring Java Classes

Each Java class you want to use in a COBOL program must be declared in the Repository paragraph. You need to provide the full name of the package the Java class is in, prefixed by $java$. The prefix tells the COBOL run-time system to load the class from the Java domain.

Declare the Java class as follows:

repository.
     class COBOL-classname as "$java$class-name"
    .

where the names are:

COBOL-classname The name by which the class is known to this COBOL program.
java The name of the Java domain.
class-name The name by which the class is known to the Java domain. This is usually determined by the name under which the class has been registered with the object model for that domain.

For example:

repository. 
     class jRectangle as "$java$java.awt.Rectangle" 
     .

This declares jRectangle as a COBOL proxy object for the Rectangle class in the java.awt package. The package must be available on your Java classpath or your program will fail at run time.