What you have recommended closely mirrors what I typically do.
Each utility or app has its own IFS folder contains the class/program and any related JAR files.
Then I set JAVA_HOME for the JVM to use.
In my case I avoid RPG and Java together like the plague because of the single instance issues.
I typically run my classes using QSHELL or an app server if I need it to stay loaded.
The benefit to this is I can alter the JVM and CLASSPATH variables and run two different java utilities in the same job even if they have differenet JVM / Classpath requirements.
Regards,
Richard Schoen
Director of Document Management
e. richard.schoen@xxxxxxxxxxxxxxx
p. 952.486.6802
w. helpsystems.com
------------------------------
message: 5
date: Fri, 19 Jan 2018 07:24:42 -0500
from: Mark Murphy <jmarkmurphy@xxxxxxxxx>
subject: Re: Java extensions directory vs Excel generation
Here is my SETUPJVM program. You will notice that all my java libraries are
in an IFS folder named java, and each tool/version has it's own folder (for
the most part). In addition, I am setting the CLASSPATH differently for
test and production. I could set the CLASSPATH based on a parameter if I
needed to use a different version of POI.
PGM
DCLPRCOPT DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR(JCS) +
USRPRF(*OWNER)
DCL VAR(&POINTER) TYPE(*PTR)
DCL VAR(&ENV) TYPE(*CHAR) LEN(4)
DCL VAR(&RMTDEBUG) TYPE(*CHAR) LEN(1)
DCL VAR(&JOB) TYPE(*CHAR) LEN(10)
DCL VAR(&USER) TYPE(*CHAR) LEN(10)
/* Start Remote Debug JVM if requested */
RTVJOBA JOB(&JOB) USER(&USER)
RTVDTAARA DTAARA(RMTJVADBG (1 1)) RTNVAR(&RMTDEBUG)
MONMSG MSGID(CPF1015)
IF COND(&RMTDEBUG *EQ 'Y' *AND &USER = +
'MURPHYMDEV') THEN(DO)
CALL SETUPJVMD
CHGDTAARA DTAARA(RMTJVADBG (1 1)) VALUE('N')
GOTO OUT
ENDDO
/* Normal JVM */
CALL PGM($ENVTYPE) PARM(&ENV)
/* Test CLASSPATH */
IF (&ENV = 'TEST') DO
ADDENVVAR ENVVAR(CLASSPATH) +
VALUE('+
/java/poi-3.14/poi-3.14-mx-dev.jar:+
/java/poi-3.14/poi-ooxml-3.14-mx-dev.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-dev.jar:+
/java/metalex/reports-dev.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;+
-Dos400.stderr=file:/home/murphymdev/stderr.txt;+
-Djava.net.preferIPv4Stack=true;+
') REPLACE(*YES)
ENDDO
/* Production CLASSPATH */
ELSE DO
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;+
-Djava.net.preferIPv4Stack=true;+
') REPLACE(*YES)
ENDDO
ADDENVVAR ENVVAR(QIBM_USE_DESCRIPTOR_STDIO) VALUE('Y')
REPLACE(*YES)
ADDENVVAR ENVVAR(JAVA_HOME) +
VALUE('/QOpenSys/QIBM/ProdData/JavaVM/jdk80/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 came from Scott Klement's HSSFR4 service program. I
had to add export to the procedure definition to use it. I call this
program at the start of every job that needs to write to Excel or Word. I
also recommend submitting these jobs to batch as you can't restart the JVM
later in the same job if you need a different CLASSPATH.
On Thu, Jan 18, 2018 at 11:03 PM, Mark Murphy <jmarkmurphy@xxxxxxxxx> wrote:
If you search the archives, you should find a CL that I posted to set up
the JVM. I recommend keeping just a single version of poi in your classpath
at a time. If you can't find the CL, I can repost it. If you really need
all those versions, maybe you could have multiple versions of your setup
program, and call the correct one at the beginning of each job that uses
poi. But, I believe all the versions you have listed are compatible with
each other.
On Jan 18, 2018 10:46 AM, "Rob Berendt" <rob@xxxxxxxxx> wrote:
We've been given grief by IBM for an unrelated issue for having these
objects in the directory they are in
/QIBM/UserData/Java400/ext/poi-ooxml-schemas-3.14-20160307.jar
/QIBM/UserData/Java400/ext/poi-ooxml-schemas-3.14-20160307.jar
/QIBM/UserData/Java400/ext/ooxml-security-1.1.jar
/QIBM/UserData/Java400/ext/cellutil.jar
/QIBM/UserData/Java400/ext/dom4j-1.6.1.jar
/QIBM/UserData/Java400/ext/jsr173_1.0_api.jar
/QIBM/UserData/Java400/ext/jtds-1.2.5.jar
/QIBM/UserData/Java400/ext/poi-3.14-20160307.jar
/QIBM/UserData/Java400/ext/poi-ooxml-3.14-20160307.jar
/QIBM/UserData/Java400/ext/poi 3.10.1 backup
/QIBM/UserData/Java400/ext/ooxml-schemas-1.3.jar
/QIBM/UserData/Java400/ext/poi-3.10.1 - current
/QIBM/UserData/Java400/ext/poi3.14 new testing
/QIBM/UserData/Java400/ext/stax-api-1.0.1.jar
/QIBM/UserData/Java400/ext/xmlbeans-2.6.0.jar
It has been recommended that they are left in their appropriate
directories.
http://www-01.ibm.com/support/docview.wss?uid=nas8N1014801
Some questions:
1 - Where should I be using instead?
2 - Do I search for these same objects or does Java know to look in the
jar files for the stuff it needs? IOW some newer version of Java may call
the same function but out of file poi....3.25...jar instead of
poi....3.14...jar.
3 - What do others, who use the java stuff to generate excel, do?
I expect some response from someone who uses some other utility to
generate spreadsheets (such as python) but that really doesn't help me
clean up this java. So, yes I am aware of alternatives, but no, instead
of pursuing them I want to clean this up instead.
Rob Berendt
--
As an Amazon Associate we earn from qualifying purchases.