Calling the Java Virtual Machine (JVM) DLL or Shared Library

If desired, you can invoke a Java program from COBOL by calling the JVM shared library or DLL and then invoking the routines in that library. In the case of JRE 1.4.2_04, these files are called "jvm.dll" and "libjvm.so". You can call these files in one of two ways:

  1. Load the JVM shared library or DLL into your COBOL program using the CALL statement, then make calls to the JVM functions. For example, in UNIX:
    CALL "libjvm.so"
    CALL "JVMfunction"

    For more information on calling DLLs and shared libraries and their functions, see Working with Windows Technologies and Using ActiveX Controls and COM Objects.

    In Windows, you can CALL the DLL to load it, as shown here:

    CALL "JVM.dll"

    Then you can call any of the routines contained in the DLL using the direct C interface. This is described in Working with C and C++ Programs.

  2. Call the JVM through C. ACUCOBOL-GT can make calls to C, and C can make calls to the JVM. See Working with C and C++ Programs for information on how to call C subroutines from ACUCOBOL-GT.