View previous topic :: View next topic
|
Author |
Message |
danik56
New User
Joined: 08 Mar 2017 Posts: 56 Location: Israel
|
|
|
|
The IBM COBOL version 6.3 doc states that a 64-bit COBOL program can only call Java using JNI and not via INVOKE.
Can someone point me at some example for using JNI to call Java from a COBOL batch program compiled with LP(64) option ? |
|
Back to top |
|
 |
Pedro
Global Moderator

Joined: 01 Sep 2006 Posts: 2600 Location: Silicon Valley
|
|
Back to top |
|
 |
danik56
New User
Joined: 08 Mar 2017 Posts: 56 Location: Israel
|
|
|
|
This sample code only works in AMODE 31.
If the COBOL program is AMODE 64, the INVOKE command is not supported for calling a Java method.
Only JNI can be used to call Java in Amode 64.
I was looking for sample code where JNI is used to call Java. |
|
Back to top |
|
 |
danik56
New User
Joined: 08 Mar 2017 Posts: 56 Location: Israel
|
|
|
|
We made some progress but still having issues.
Here is the JCL we have used to compile & bind a COBOL program that invokes JNI services:
//RUN EXEC IGYQCB,LIBPRFX=CEE,LIBPRF1=CEE,
// PGMLIB='YOSI.TEST.LIB',GOPGM=HLWRLD64
//COBOL.SYSIN DD DSN=Z2V10.SAMP.LIB(CBLB#JNI),DISP=SHR
//COBOL.SYSLIB DD DSN=Z2V10.SAMP.LIB,DISP=SHR
// DD DSN=DANI.SOURCE.LIB,DISP=SHR
//COBOL.SYSLIN DD DSNAME=&&OBJECT(HLWRLD64),
// DISP=(NEW,PASS),SPACE=(CYL,(1,1,1)),DCB=(LRECL=80,RECFM=FB)
//BIND.OBJMOD DD DSN=&&OBJECT,DISP=(OLD,DELETE)
//BIND.SYSLIN DD *
INCLUDE OBJMOD(HLWRLD64)
INCLUDE '/usr/lpp/java/J8.08.15/J8.0_64/bin/j9vm/libjvm.x'
INCLUDE '/usr/lpp/IBM/cobol/igyv6r3/lib/igzcjava.x'
//
The result:
-STEPNAME PROCSTEP RC
-RUN COBOL 00
-RUN BIND 00
Compiler options used: cbl dll,lp(64),rent,pgmname(longmixed)
First JNI call is successfull:
CALL "JNI_CreateJavaVM"
USING JVM-PTR ENV-PTR VM-INIT-ARGS
RETURNING INTO RC2.
RETURNING RC2.
DISPLAY "rc2 " RC2 " " JVM-PTR " " ENV-PTR
IF RC2 NOT = 0
GOBACK
END-IF
The problem we have is related to the 2ed JNI call:
CALL FindClass USING BY VALUE ENV-PTR
CLASS-NAME-PTR
RETURNING MY-CLASS-REF.
DISPLAY "PNT1B"
DISPLAY "1." MY-CLASS-REF.
IF MY-CLASS-REF = 0
GOBACK
END-IF
This call returns null value although the requested java class exists as a jar file in the folder pointed by env
variable CLASSPATH.
There is nothing in STDOUT & STDERR datasets.
My question is how to turn on some tracing options so we can see why the FindClass JNI call is failing. |
|
Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1353 Location: Bamberg, Germany
|
|
|
|
Why have you quoted this routine:
CALL "JNI_CreateJavaVM"
but not:
CALL FindClass USING BY VALUE ENV-PTR |
|
Back to top |
|
 |
danik56
New User
Joined: 08 Mar 2017 Posts: 56 Location: Israel
|
|
|
|
The JNI block has this field:
02 FindClass function-pointer.
We thought it gets populated after the create JVM call.
Is that incorrect ? |
|
Back to top |
|
 |
|