Setting System.property by JZOS-invocation-JCL

General discussion on the JZOS batch launcher and toolkit
Post Reply
Ulrich Schmidt
Posts: 37
Joined: Fri Jan 09, 2009 1:25 pm
Location: Germany

Setting System.property by JZOS-invocation-JCL

Post by Ulrich Schmidt »

Hello,

is there an opportunity to provide the jobname to the java program. I'like to set it by -Djobame= to be used as system property, but I would like to do so by invoking the class in the JCL.
I won't use the JZOSENV-file for this.

brgds,
Ulrich Schmidt
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

Ulrich,

I can think of two ways to pass a system property from JCL parameters into a JZOS batch job:

1) pass the parameter as an argument to your main() method and then have the main method use that argument with System.setProperty(). This requires that you modify the Java main class.

2) set an environment variable from the JCL, and then in your STDENV script use that environment variable to set the property in IBM_JAVA_OPTIONS:

Code: Select all

// EXEC JVMPRC60,LEPARM='ENVAR(JOBNM=&JOBNM)',
//      JAVACLS='com.myco.Myclass'
//STDENV DD *
...
# Configure JVM options
IJO="-Xms16m -Xmx128m"
IJO="$IJO -Djobname=&JOBNM"
export IBM_JAVA_OPTIONS="$IJO "
//  
Ulrich Schmidt
Posts: 37
Joined: Fri Jan 09, 2009 1:25 pm
Location: Germany

Post by Ulrich Schmidt »

I like the second solution.
But get it run I have to change at two positions:
LEPARM='ENVAR(JOBNM=<realJobname>',

and

IJO="$IJO -Djobname=$JOBNM"

which means, the jobname ist filled in dynamically - I have to edit the real jobname to the LEPARM-Field,
and instead of &JOBNM I have to use $JOBNM to see the <realJobname> in my System.getProperty("jobname").

brgds,
Ulrich
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

Sorry, that was a typo, I meant to have:

IJO="$IJO -Djobname=$JOBNM"

I meant to allow LEPARM to be set for a &JOBNM JCL variable, but your solution is fine.
Post Reply