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                  

# java program to compile (or *.java)                                    

# java package subdirectory -- based upon programs' package statement(s) 

# CICS environment (test, QA, production)         

# Our companies location for CICS java app class files

# Locate java & cics                                                     

# build paths for compiling                                              

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

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 *