This example demonstrates how the JVM COBOL run-time system uses a Java property file, created using the mfjarprogmap utility, to call a program that was compiled as part of a package. This example uses the CLASSPATH in order to locate the Java property file.
program-id myapp. procedure division. display "Hello world from myapp". goback. end program myapp.
program-id caller. procedure division. call "myapp". goback. end program caller.
mkdir bin
Windows:
cobol caller.cbl jvmgen; cobol myapp.cbl jvmgen(sub) iloutput(bin) ilnamespace(com.mycompany.desktopapp);
UNIX:
cob -j caller.cbl cob myapp.cbl -C 'jvmgen(sub)' -C 'iloutput(bin)' -C 'ilnamespace(com.mycompany.desktopapp)'A caller.class file is created in your current directory, and the myapp.class file is created in the bin\com\mycompany\desktopapp (Windows), bin/com/mycompany/desktopapp (UNIX) directory.
mfjarprogmap -verbose -directory binThe mfcobolprogmap.properties file is created in the bin directory.
jar cvf myapp.jar -C bin/ .myapp.jar is created in the current directory.
Windows:
java -classpath myapp.jar;.;%CLASSPATH% caller
UNIX:
java -classpath myapp.jar:.:$CLASSPATH callerThe run-time system uses the Java property file within the .jar file to locate the program being called by caller.class, which results in the Hello world from myapp message being displayed.