



                JCL for Java
                
                I notice I have access to HFS files via the PATH=
                JCL parameter
                
                when I access HFS files/directory I MUST remember they are case sensitive
                and the path start at root '/'
                
                -------------------------------------------------
                
                IBM provides 2 utility programs to invoke Java from JCL
                
                1) BPXBATCH, is LIMITED to the 4 standard Java DD cards
                              this means I CANNOT use DD cards for file input/output
                              
                2) BPXBATSL, this uses the 4 standard Java DD cards, and support
                              any other DD card you wish to use
                
                they can run:
                
                A) a Unix Shell command
                     PARM='SH ....'
                B) a Unix executable Program
                     PARM='PGM ...'
                     
                     
                Java appl runing via JCL can use (there are defaults) these DD cards:
                
                STDIN -> this is Standard input to the Java code (not used very much)
                
                STDOUT -> this is Standard Output from the Java code (this is Java
                            writing to the Console)
                            
                STDERR -> this is Standard Error output
                            WRNING this is where Java error messages will go, 
                            if you do not have STDERR you will NOT see the messages
                            
                            
                STDENV -> this is setting the Unix execution enviroment to run Java
                           I use this to set:
                           JAVA_HOME -> which Java I am using for this run
                           CLASSPATH -> the dir(s) hold the jars for this run
                           PATH -> the dir(s) to include in the executable path
             
             
             I can get JCL messages, whcih I will see in the JES output 
             
             I can get Java message, which I will NOT see in teh JES out, but I 
             see in STDERR
             
             If I have a Java Error I will see these Condition Codes:
             
       when using BXPBATCH I have the following Condition Codes:
        0001 -> there was a Java error check the STDERR file
                 typical error include:
                  cannot find main class (the jar/class name wrong)
                  uncaught exception in code
        
        0126 <- I am use a Unix Shell script, and that script is NOT executable
                         so the JCL cannot run it
                         
        0127 <- the JCL cannot find the Unix Shell script, so check
                        the name, spelling, path, etc  
                        
        00xx <- this is the return code from your Java
                         System.exit(xx)   
                         if the Java developer provides a negative value
                         I get a "strange" condition code
                     
                
        when using BXPBATSL I have the following Condition Codes:
        0256 -> there was a Java error check the STDERR file
                 typical error include:
                  cannot find main class (the jar/class name wrong)
                  uncaught exception in code
        
        0381 <- I am use a Unix Shell script, and that script is NOT executable
                         so the JCL cannot run it
 
        0382 <- the JCL cannot find the Unix Shell script, so check
                        the name, spelling, path, etc



        -------------------------------------------------------
        
        WARNING: Java error go to STDERR not JES, however I can copy those
                 errors to JES output by adding a new JCL step
                 
//BPXBATCH JOB (999,XXX),'JAVA BPXBATCH',CLASS=A,MSGLEVEL=(1,1)
// MSGCLASS=X,REGION=0M,NOTIFY=&SYSUID
//********************************************************************
//* Run Java under a UNIX System Service shell
//********************************************************************
//STEP2 EXEC PGM=BPXBATCH,
// PARM='SH java com.foo.MyClass arg1 arg2'
//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/classes
//*********************************************************************
//* 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)
//                 


------------------------------------------------------------

On the class web site I have

JCLPlay1
  uses BPXBATCH
  and write to STDOUT and STDERR as part of the Java code, it then divides by Zero
   and I get Cond Code of 0001 and I look at the STDERR file for the Java messages
   I DO NOT see the messages as part of JES
   If I bypass the Divide By Zero, the code does System.exit(4) so I get a 
   Condition Code = 4 
   
JCLPlay2
  uses BPXBATSL to access a DD card form insdie the Java code, 1 of the DD cards points
  to a HFS (Unix) files, the other card points to an MVS file
  this JCL also uses a file to build STDENV
  
JCLPlay3
  uses BPXBATCH to execute a Unix Shell script that has all the Java files in it
  rememebr CC 0126/0127 deal with Shell Scripts
  
JCLPlay4
   used BPXBATSL and a number of DD cards to control I/O
   
