COBOL

COBOL

COBOL

COBOL is responsible for the efficient, reliable, secure, and unseen day-to-day operations of the world's economy.

 View Only
  • 1.  Setting up JNI for calling Java from batch COBOL program on z/OS

    Posted Tue November 21, 2023 01:08 AM

    The IBM COBOL version 6.3 doc states that a 64-bit COBOL program can only call Java using JNI interface and not via INVOKE.
    Can someone point me at some COBOL code example for using JNI to call Java from a COBOL batch program compiled with LP(64) option ?



    ------------------------------
    Dan Kalmar
    ------------------------------


  • 2.  RE: Setting up JNI for calling Java from batch COBOL program on z/OS

    Posted Wed November 22, 2023 07:51 AM

    Hi Dan,

    The COBOL Programming Guide contains some JNI examples that are specific to using z/OS Java ie. accounting for EBCDIC vs. UTF-8 (mostly ASCII) issues. JNI as a whole is a subject a bit to large to go into here.

    But COBOL 6.4 provides a Java Interoperability (JAVAIOP) feature that generates the interface code required to call static methods from COBOL, for your COBOL program to be called from Java, and access functions to share working-storage items with Java code. This feature typically takes a lot of the grunt work out of Java interfacing that using JNI directly exposes you to. Various aspects of this are covered in the COBOL Language Reference and User Guide.

    Bernie



    ------------------------------
    Bernie Rataj
    Technical Support Professional
    IBM Canada Ltd.
    Markham ON Canada

    https://www.ibm.com/products/cobol-compiler-zos
    https://www.ibm.com/products/pli-compiler-zos
    ------------------------------



  • 3.  RE: Setting up JNI for calling Java from batch COBOL program on z/OS

    Posted Wed November 22, 2023 11:20 AM
    Edited by Dan Kalmar Wed November 22, 2023 11:21 AM

    Thanks for the insight Bernie.

    In particular my question related to calling a Java method from a COBOL program compiled at 6.3 level.

    Initially I was trying to use the INVOKE command from a COBOL program compiled with LP(64) option.

    There was an error saying INVOKE is not allowed in AMODE 64.

    So next I thought I should try to use JNI to call the Java method in 64 bit mode.

    I understand I need to figure out how to use JNI from COBOL but maybe you can just indicate if this approach can work with COBOL at 6.3 level

    or would we be better off to upgrade to COBOL 6.4 ?



    ------------------------------
    Dan Kalmar
    ------------------------------



  • 4.  RE: Setting up JNI for calling Java from batch COBOL program on z/OS

    Posted Wed November 22, 2023 01:35 PM

    Dan, would definitely be better off upgrading to COBOL 6.4, as there are significant improvement to COBOL<->Java interop (NEW framework that does not depend on OO COBOL).
    This JNI technote does talk about the old method, but IBM's strong recommendation is to use the new framework in 6.4

    https://www.ibm.com/support/pages/node/6320801

    Since this is such a popular topic, our team created a COBOL/Java interop portal for consolidated information - https://www.ibm.com/docs/en/c-and-ji?topic=cobol-java-interoperability
    Welcome any feedback ("Give Feedback" button) for further portal improvements.



    ------------------------------
    James Tang
    ------------------------------