Compiling a java Program for CICS

By | October 15, 2013

You might want to use JCL to compile java programs for your CICS environment. Probably, you already have standard procedures for compiling other language types. Java source programs compile into class files which must be in the Unix file system instead in load libraries. So, just as you would have separate libraries for separate development stages (test, QA, production), you should have separate sub-directories for these as well.

This information pertains to the java environment prior to CICS TS 5.1.  For the JVM Server OSGi environment, things are different.  See my later post, regarding this.

The JCL below is an example showing how you might compile one of the sample CICS java programs provided by IBM.  In this example, the class files are stored in/home/cicsts/java/test/classes/. This has to correspond with the CLASSPATH specified in the JVM profile set up when java is implemented in the CICS region.  In this case, that would be CLASSPATH_SUFFIX=/home/cicsts/java/test/classes.  And the classes are in subdirectory examples/Web as indicated by the package statement in the source.

package examples.Web;

Here’s the JCL:

//JAVAC    EXEC PGM=AOPBATCH,REGION=120M,PARM='//bin/sh'                 
//STDOUT   DD  SYSOUT=*                                                  
//STDERR   DD  SYSOUT=*                                                  
//SYSPRINT DD  SYSOUT=*                                                  
//SYSOUT   DD  SYSOUT=*                                                  
//STDIN    DD  *                                                         
# source directory -- where source code has been placed                  
SRC_ROOT="/usr/lpp/cicsts/cicsts41/samples/dfjcics/examples/Web"         

# java program to compile (or *.java)                                    
PGM="Sample1.java"                                                       

# java package subdirectory -- based upon programs' package statement(s) 
APP_PATH="examples/Web"                                                  

# CICS environment (test, QA, production)         
CICSENV="test"                                                            

# Our companies location for CICS java app class files
CICSJAVA="/home/cicsts/java"                                          

# Locate java & cics                                                     
JAVA_HOME="/usr/lpp/java/J6.0.1"                                         
CICS_HOME="/usr/lpp/cicsts/cicsts41"                                     

# build paths for compiling                                              
DST_PATH="${CICSJAVA}/${CICSENV}/classes"                                
JAVAC_CPATH="${DST_PATH}/*:${CICS_HOME}/lib/*"                           
PATH=${JAVA_HOME}/bin:${PATH}                                            

mkdir -p -m 775 ${DST_PATH}/${APP_PATH}                                  
javac -classpath ${JAVAC_CPATH} \                                        
  -d ${DST_PATH} \                                                       
  ${SRC_ROOT}/${PGM}                                                     
/*

The CSD entry for this program is in group DFH$JVM, program name DFJ$JWB1, and it has JVMClass(examples.Web.Sample1) specified. The CICS JVM finds the correct class file from the CLASSPATH and, interpreting the ‘.’ as subdirectory delimiters, the JVMClass, so the full path builds to /home/cicsts/java/test/classes/examples/Web/Sample1.class.

Leave a Reply

Your email address will not be published. Required fields are marked *