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
Original Message:
Sent: Wed November 22, 2023 11:20 AM
From: Dan Kalmar
Subject: Setting up JNI for calling Java from batch COBOL program on z/OS
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
Original Message:
Sent: Wed November 22, 2023 07:50 AM
From: Bernie Rataj
Subject: Setting up JNI for calling Java from batch COBOL program on z/OS
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
Original Message:
Sent: Tue November 21, 2023 01:07 AM
From: Dan Kalmar
Subject: Setting up JNI for calling Java from batch COBOL program on z/OS
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
------------------------------