Search code examples
javamainframezosjcl

JZOS Batch launcher - Run JCL job with java source code within SYSIN DD *


JOB Description: JVMLDM76 library is in the dataset WLM.ABC.DEF.LINKLIB.PDSE. JVMLDM76(load module) comes with jzos batch launcher tool kit installation.

Here is my job:

    //JHELLO JOB MSGLEVEL=(1,1),REGION=0M,CLASS=Q,MSGCLASS=A 
    /* NOTIFY=&SYSUID */                                     
    //JOMVS EXEC PGM=JVMLDM76,REGION=0M,TIME=NOLIMIT         
    //STEPLIB  DD DSN=WLM.ABC.DEF.LINKLIB.PDSE,DISP=SHR  
    //SYSIN    DD  *                                         
    /* program starts here */                                
    public class JHelloWorld                              
    {                                                     
        public static void main(String args[])              
        {                                                  
           System.out.println("Hello :)");                 
        }                                                  
    }                                                    
    //*                                                      
    //STDOUT   DD SYSOUT=*                                   
    //SYSPRINT DD SYSOUT=*                                   
    //STDERR   DD SYSOUT=*                                   
    //

Error:

No java class name argument supplied. Jzos batch launcher failed, return code=101

Queries:

  1. Can i send java program only as class file like JOMVS EXEC PGM=JVMLDM76,REGION=0M,TIME=NOLIMIT,JAVACLS = Hello ?(this works fine)

  2. Is there any way to integrate java source code with jcl ? I cannot change load module. It is encrypted.

  3. While i am transferring my java program from workstation to host (ascii transfer mode), Special character [] in program at 'main(String args[])' is getting disappeared. If i type it in jcl, it is working fine. can someone tell reason for this ? i have seen this link.but, didnt find any documentation regarding this. Is there a list of Special characters to be avoided in JCL/MVS Script variables

Thanks for your attention,


Solution

  • Java is not an interpreted language. It needs to be compiled into a bytecode *.class or *.jar file and then executed. To do what you want to do would require a more sophisticated batch launcher like Co:Z batch from Dovetailed technologies https://dovetail.com/docs/coz/coz_index.html. Dovetailed are the original authors of JZOS.

    //COZBATCH JOB CLASS=W,NOTIFY=&SYSUID                                  
    //*                                                                    
    //JOBLIB  DD DISP=SHR,DSN=COZ.LOADLIB                                  
    //*                                                                    
    //*====================================================================
    //* Batch job to run the CoZLauncher.                                  
    //*====================================================================
    //RUNCOZ  EXEC PGM=COZBATCH                                            
    //STDIN  DD *                                                          
    cd /tmp                                                                
    mkdir -p hello                                                         
    cd hello                                                               
    cat >HelloWorld.java <<EOF                                             
    public class HelloWorld {                                              
       public static void main(String[] args) {                            
            System.out.println("Hello World!");                            
       }                                                                   
    }                                                                      
    EOF                                                                    
    export JAVA_HOME=/usr/lpp/java/J7.1_64                                 
    export PATH=$PATH:$JAVA_HOME/bin                                       
    javac HelloWorld.java                                                  
    java HelloWorld                              
    /*