ACUCOBOL-GT includes several configuration variables for calling Java via the C$JAVA routine.
|PRELOAD_JAVA_LIBRARY||Tells the runtime to preload the JVM on startup|
|JAVA_LIBRARY_NAME||Specifies the name and path of the JVM library to load|
|JAVA_OPTIONS||Specifies Java command-line options|
|A_JAVA_TRACE_FILENAME||Names the file where you want to store JVM call trace information|
|A_JAVA_TRACE_VALUE||Specifies the types of calls to trace|
|A_JAVA_GC_COUNT||Specifies how often the runtime should call the JVM garbage collector|
|A_JAVA_CHARSET||Specifies the character set that the runtime should use when mapping Java strings or PIC X data items containing characters outside of the ISO-8859-1 range. The default setting is "IS0-8859-1".|
All of these variables are optional. If desired, you include them in your runtime configuration file, just as you would any ACUCOBOL-GT configuration variable. See Configuration Variables for details on using these variables.
For Java interoperability, your configuration file may look like this:
PRELOAD_JAVA_LIBRARY 1 JAVA_LIBRARY_NAME jvm.dll (Windows) JAVA_LIBRARY_NAME libjvm.so (UNIX) JAVA_OPTIONS -Djava.library.path=c:\java\lib -Xms128m -Xmx128m -classpath c:\java\MyClasses\myclasses.jar (Windows) JAVA_OPTIONS -Djava.library.path=/java/lib -Xms128m -Xmx128m -classpath /java/MyClasses/myclasses.jar (UNIX)
Both CLASSPATH (java.class.path system property) and the java.library.path must be configured in order for C$JAVA to locate the Java class to run. The CLASSPATH is the location of ".jar" or ".class" files. The java.library.path is the location DLLs or shared objects that are required either by the runtime or by the Java Virtual Machine (JVM).
You can set these properties using the JAVA_OPTIONS variable. This is the first place that the runtime looks when trying to call Java from COBOL. If you prefer, you can set them in the environment: