Java on z/OS includes a rich 'Toolkit'
The JZOS Toolkit consists of classes in package com.ibm.jzos, which is distributed with the IBM Java SDKs for z/OS.
JZOS Toolkit capability includes:
- High performance interface for reading and writing sequential data sets in record mode
- An interface for various z/OS native functions
- BufferedReader, BufferedWriter, InputStream, or OutputStream on a text file or a MVS dataset
- An interface to the MVS Operator console and job log
- A thin wrapper for many of the z/OS C library I/O functions
- Sample programs
If you are an experienced Java programmer and want JZOS Toolkit package syntax:Overview (IBM JZOS Toolkit API)
A Java program "imports" the JZOS Toolkit to use the toolkit features.
A Java source code compile problem is reported. The reported problem is related to a simple Java syntax error. The Java syntax problem can be identified without being a Java programmer. The Java compile error message provides information needed to resolve the problem.
You will copy Java source code to a file in your Unix directory. JCL is used to compile and execute the source code. The output of the Java program is written to member #06 in your P3.OUTPUT partitioned data set upon successful resolving the compile and execution issues.
Copy Java source to your Unix directory
Yet another way to copy between MVS data sets and Unix filesystems:
- From ISPF, enter =6 to jump to the ISPF Command Shell panel
You can enter TSO commands from the ISPF Command Shell panel
- Enter oput 'zos.mtm2019.public.p3.source(zjava)' 'zjava.java'
View the Java source in your Unix subdirectory
Yet another way to edit Unix files:
- Enter oedit
Your Unix subdirectory with file names is displayed
- Edit e to the left of zjava.java to view the Java source code
- Line 1 imports the IBM JZOS Toolkit
- Line 7 shows the data to be read is from JCL DDNAME //RECIN
- Line 10 declares variable nRead as an integer
nRead declared variable is significant in resolving syntax error during compile
- Line 12 reads a text line into string variable rec
- Line 13 replaces Who said this with Albert Einstein
- Line 13 variable newRec has the modified text
- Line 14 writes the content of newRec
- Line 15 results in reading the next text line
Submit JCL to compile and execute Java source program
From the Unix file edit session, submitting JCL and jumping to SDSF is possible.
- Enter tso sub 'zos.public.jcl(zjava)' ; =sd ;st
Identify and correct Java compile error
DDNAME STDERR output from JCL job ZJAVA includes an error message.
What was the name of integer value declared early in the Java program?
A mark exists just below the source line flagging the location of the error found by the compiler.
- enter tso oedit
- edit zjava.java
- correct the syntax error
- enter tso sub 'zos.public.jcl(zjava)' ; =sd ;st
- view the output
If compiled was unsuccessful, then edit the source again to identify and correct the problem.
If compile was successful, proceed to the next part of the challenge.
What did you just learn?
You identified and corrected a Java source code syntax error reported by the compiler.
Feel free to check your P3.OUTPUT(#06) which should contain the following quote:
"I have no special talent. I am only passionately curious."