Execute java from batch JCL
Asked Answered
U

1

7

In the past I have used BPXBATCH to execute java class files from JCL. I would like to move to using the custom JVM launcher as IBM recommends in the link below. http://www.ibm.com/developerworks/systems/library/es-java-batchz.html

I wrote up a hello world java program and compiled it on the mainframe and packaged it into a jar.

Below is an example JCL member using BPXBATCH that works.

//LMGHWRLD JOB (MY,ACCOUNTING,INFO),'HELLO WORLD',                   
//   CLASS=A,MSGCLASS=H,REGION=512M,NOTIFY=&SYSUID                     
//******************************************************************** 
//* Run Java under a UNIX System Service shell                         
//******************************************************************** 
//STEP2 EXEC PGM=BPXBATCH,                                             
// PARM='SH java com.foo.bar.HelloWorld'                  
//STDIN  DD DUMMY                                                      
//STDOUT DD PATH='/tmp/&SYSUID..bpxbatch.out',                         
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),                                   
// PATHMODE=SIRWXU                                                     
//STDERR DD PATH='/tmp/&SYSUID..bpxbatch.err',                         
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),                                   
// PATHMODE=SIRWXU                                                     
//STDENV DD *                                                          
CLASSPATH=/u/myuid                                                
//*********************************************************************
//* Copy HFS output files to SYSOUT, since BPXBATCH can only write     
//* STDOUT and STDERR to HFS files.                                    
//*********************************************************************
//STEP3 EXEC PGM=IKJEFT01,DYNAMNBR=300,COND=EVEN                       
//SYSTSPRT DD SYSOUT=*                                                 
//HFSOUT DD PATH='/tmp/&SYSUID..bpxbatch.out'                          
//HFSERR DD PATH='/tmp/&SYSUID..bpxbatch.err'                          
//STDOUTL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=133,BLKSIZE=137)             
//STDERRL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=133,BLKSIZE=137)             
//SYSPRINT DD SYSOUT=*                                                 
//SYSTSIN DD *                                                         
OCOPY INDD(HFSOUT) OUTDD(STDOUTL)                                      
OCOPY INDD(HFSERR) OUTDD(STDERRL)                                      
//                                                                     

I would like to use all the features using the custom JVM launcher brings as detailed in the article above.

The example above executes class files, but the article seems to suggest JAR files are needed for the custom JVM launcher. Below is the job I created to try and use the custom JVM launcher.

The JAR file is ~/HelloWorld/HelloWorld.jar on OMVS.

//LMGHWRLD JOB (MY,ACCOUNTING,INFO),'HELLO WORLD', 
//   CLASS=A,MSGCLASS=H,REGION=0M,NOTIFY=&SYSUID     
//STEP1    EXEC PGM=JVMLDM60,                        
//   PARM='com.foo.bar.HelloWorld'      
//STEPLIB  DD DSN=<MY.LIBRARY.PATH>,DISP=SHR
//SYSPRINT DD SYSOUT=*                               
//SYSOUT   DD SYSOUT=*                               
//STDOUT   DD SYSOUT=*                               
//STDERR   DD SYSOUT=*                               
//STDENV   DD *                                      
. /etc/profile                                       
. ~/.profile                                         
export CLASSPATH=~/HelloWorld                        
for i in ~/HelloWorld/*.jar; do                      
    export CLASSPATH=$i:$CLASSPATH                   
    done                                             
//     

Currently the output of this job fails with a CC of 102. The specific output is below:

JVMJZBL1001N JZOS batch Launcher Version: 2.3.0 2013-05-02     
JVMJZBL1002N Copyright (C) IBM Corp. 2005. All rights reserved.
JVMJZBL1038E Child shell process exited with exit code: 1      
JVMJZBL1042E JZOS batch launcher failed, return code=102       

My region size is 200,000 so I don't believe region size is the issue. Is there something I am doing incorrectly?

Ulcerous answered 30/3, 2015 at 18:10 Comment(4)
200,000 what? And why do you think that? On your JOB card you have 0M. Did you try 200M?Papillon
You might want to check with the support forums Dovetailed Technologies runs. (community.dovetail.com/forum/viewforum.php?f=1)Seaddon
Hello Bill, 200,000 is the region size on my TSO session. I previously had an issue where I couldn't compile .java files so I figured I would bring it up in my post. I did try running with 256M, no luck. I'm still working on resolving it.Ulcerous
I have had to increase the size of my region from 200M to 300M with our last upgrade to z/OS 1.13. I don't recall which version of Java was installed at that time. Think big (compared to COBOL, et. al) when it comes to Java and region size.Seaddon
U
1

The resolution to this wound up being a change to the STDENV DD statement. The following code should work on any environment with the indicated areas changed.

//STDENV   DD *                                              
#                                                            
# Java home location                                         
#                                                            
export JAVA_HOME=/your/omvs/path/to/java/lib
#                                                            
# Standard java path updates                                 
#                                                            
export PATH=/bin:"${JAVA_HOME}"/bin                          
LIBPATH=/lib:/usr/lib:"${JAVA_HOME}"/bin                     
LIBPATH="$LIBPATH":"${JAVA_HOME}"/lib/s390                   
LIBPATH="$LIBPATH":"${JAVA_HOME}"/lib/s390/j9vm              
LIBPATH="$LIBPATH":"${JAVA_HOME}"/bin/classic                
export LIBPATH="$LIBPATH":                                   
#                                                            
# Define location (and version if applicable) of jar home    
#                                                            
APP_HOME=/var/location/of/your/jar                                       
CLASSPATH=$APP_HOME:"${JAVA_HOME}"/lib:"${JAVA_HOME}"/lib/ext
# Add Application required jars to end of CLASSPATH          
for i in "${APP_HOME}"/*.jar; do                             
    CLASSPATH="$CLASSPATH":"$i"                              
    done                                                     
export CLASSPATH="$CLASSPATH":                               
//                                                           
Ulcerous answered 8/5, 2015 at 18:50 Comment(3)
Gut feeling is you should have been able to test this from the "command line" TSO ISH ?Anglice
This did run in ishell/omvs. I needed it to be a batch job for job scheduling, live spool output, and visibility in sdsf.Ulcerous
Understood, but env would have been same according to account used ? BPXBATCH is just a background ISH ? Only thinking from troubleshooting aspect here. I often have to run "find" on the HFS for example. Good question in this case.Anglice

© 2022 - 2024 — McMap. All rights reserved.