I believe this is the correct method, note that Buck references stdout in the option vs. stderr. The file name can be anything you want. Also in the document that Buck provided is a statement that stdout and stderr are not redirected unless the QIBM_USE_DESCRIPTOR_STDIO environment variable is set to 'Y'. I call the following CLP from my initial program, and at the head of batch programs that call Java to ensure that the JVM is set up the way I want.
PGM
DCLPRCOPT DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR(JCS) +
USRPRF(*OWNER)
DCL VAR(&POINTER) TYPE(*PTR)
DCL VAR(&ENV) TYPE(*CHAR) LEN(4)
CALL PGM($ENVTYPE) PARM(&ENV)
ADDENVVAR ENVVAR(CLASSPATH) +
VALUE('+
/java/poi-3.14/poi-3.14-mx.jar:+
/java/poi-3.14/poi-ooxml-3.14-mx.jar:+
/java/poi-3.14/ooxml-schemas-1.3.jar:+
/java/poi-3.14/lib/commons-codec-1.10.jar:+
/java/poi-3.14/lib/commons-logging-1.2.jar:+
/java/poi-3.14/lib/log4j-1.2.17.jar:+
/java/poi-3.14/ooxml-lib/xmlbeans-2.6.0.jar:+
/java/poix/poi-extend.jar:+
/java/metalex/reports.jar:+
/java/javamail/javax.mail.jar:+
/java/rpgmail/rpgmail.jar:+
/java/prod/lib/mxSqlSvrJdbc.jar:+
/java/prod/lib/sqljdbc.jar:+
/java/prod/classes/cribMaster+
') LEVEL(*JOB) REPLACE(*YES)
ADDENVVAR ENVVAR(QIBM_RPG_JAVA_PROPERTIES) +
VALUE('+
-Djava.awt.headless=true;+
') REPLACE(*YES)
ADDENVVAR ENVVAR(QIBM_USE_DESCRIPTOR_STDIO) VALUE('Y') REPLACE(*YES)
ADDENVVAR ENVVAR(JAVA_HOME) +
VALUE('/QOpenSys/QIBM/ProdData/JavaVM/jdk626/32bit'+
) REPLACE(*YES)
ADDENVVAR ENVVAR(QIBM_RPG_JAVA_EXCP_TRACE) VALUE('Y') REPLACE(*YES)
CALLPRC PRC(START_JVM) RTNVAL(&POINTER)
OUT: ENDPGM
The procedure start_jvm is exported from Scott's HSSF service program.
Mark Murphy
Atlas Data Systems
mmurphy@xxxxxxxxxxxxxxx
-----Buck Calabro <kc2hiz@xxxxxxxxx> wrote: -----
To: rpg400-l@xxxxxxxxxxxx
From: Buck Calabro <kc2hiz@xxxxxxxxx>
Date: 12/02/2016 10:40AM
Subject: Re: java calls in rpgle - force screen output to file
On 12/2/2016 10:28 AM, Gerald Magnuson wrote:
while I am debugging rpgle - jni program, a shell screen pops up, and
doesn't stay long enough for me to see what it is saying....
I tried to do "CRTENVVAR QIBM_RPG_JAVA_PROPERTIES
'-Dos400.stderr=file:stderr.txt;'
and that did indeed create a file "stderr.txt", but it was empty...
I think I need to add a parm on my calls to *JAVA, to say to NOT output to
* (screen), but output to *FILE.... but I don't know how to do that....
how do I capture the stuff that shows up on the shell screen?
That depends on what the stuff is. Is Java doing System.out.println()?
Perhaps you can add -Dos400.stdout=file:stdout.txt to your environment.
But see QIBM_QSH_CMD_OUTPUT as well; you may need to set that to Y.
http://www-01.ibm.com/support/docview.wss?uid=nas8N1016050
As an Amazon Associate we earn from qualifying purchases.