|
Compiling a Java Program in Batch
This page describes how I compile a Java program in batch. Please note that this has nothing to do with compiling Java code for native execution (HPJ). It is for Java bytecode only. Except for executing the javac command instead of the java command, it is identical to the execution example.
My JCL looks like this:
//MYJOB01 JOB 'GARY PESKIN',MSGCLASS=S,CLASS=S,NOTIFY=&SYSUID,
// REGION=100M
//*********************************************************************
//* Java Bytecode Compile *
//*********************************************************************
//DELETE EXEC PGM=IEFBR14
//STDOUT DD PATH='/u/myhome/java01.out',
// PATHOPTS=(OCREAT,OWRONLY),
// PATHMODE=SIRWXU,
// PATHDISP=(DELETE)
//STDERR DD PATH='/u/myhome/java01.err',
// PATHOPTS=(OCREAT,OWRONLY),
// PATHMODE=SIRWXU,
// PATHDISP=(DELETE)
//*
//COMP EXEC PGM=BPXBATCH,
// PARM='sh javac HelloWorld.java'
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//STDOUT DD PATH='/u/myhome/java01.out',
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
// PATHMODE=SIRWXU
//STDERR DD PATH='/u/myhome/java01.err',
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
// PATHMODE=SIRWXU
//STDENV DD DUMMY
//*
//COMPOUT EXEC PGM=IKJEFT01,DYNAMNBR=300,COND=EVEN
//SYSTSPRT DD SYSOUT=*
//HFSOUT DD PATH='/u/myhome/java01.out'
//HFSERR DD PATH='/u/myhome/java01.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 DATA,DLM='/>'
ocopy indd(HFSOUT) outdd(STDOUTL)
ocopy indd(HFSERR) outdd(STDERRL)
/>
//
A few things to note about the JCL:
 This code actually executes the OMVS shell (BPXBATCH) which then executes the javac command.
 BPXBATCH uses STDOUT and STDERR for DDnames for the respective streams. If you omit or misspell one or both of these, the corresponding output is allocated to /dev/null which means it just seems to disappear without warning.
 There is no HFS equivalent to the "&&" prefix for temporary datasets, as far as I know, so I just create my own temporary datasets with a unique name. This can cause problems when simultaneously running multiple batch compiles because everyone is trying to create, access, and delete the same datasets. If you know of a way around this, please let me know.
 As a corollary to the previous point, BXPBATCH can only write stdout and stderr to HFS datasets, not MVS datasets. You can't use SYSOUT=* for these datasets. You have to write them out to HFS datasets and then copy them to SYSOUT datasets in the next step using the OCOPY command under batch TSO.
|