In this blog post, I wanted to write about my take-aways from the course; the very first take-away being a digital badge π₯ issued by Interskill upon the successful completion of the module.
What I learnt? π€
The course starts with some intro about Java on z/OS.
- Java source code can be compiled into Bytecode.
- Bytecode is portable such that all it needs to run is Java Virtual Machine (JVM).
- JVM is a container in which Java bytecode is executed. All Java programs must execute in a JVM.
- We do have a JVM on IBM z/OS so that Java can also be used on z/OS.
- Java on z/OS uses features provided by z/OS Unix.
- The basic Java support on z/OS is provided by the Java Software Development Kit, or Java SDK. This is a package provided at no charge by IBM. It includes the basic Java standard edition (Java SE) features including compiler, JVM, and more.
- There are several versions of the z/OS Java SDK and all the versions are equivalent to the same version provided by Oracle on other platforms.
- More than one Java SDK can be installed at the same time on z/OS.
How Java executes on z/OS?
Interskill provides an interactive window where you can type some commands and view the results. However, the commands that you can type are LIMITED and appropriate to an environment. It serves more of doing an hands-on rather than dwelling in theory. There was an interactive window that mimicked a z/OS Unix shell and there were several steps which guided me in compiling and executing a Java program from the z/OS Unix shell. I've tried and succeded in doing the same stuff on the system available via Master the Mainframe 2020. That means there is a JVM on z/OS for Unix system in MTM2020 which run Java programs.
It's time for an hands-on!π Are you ready?
Compiling a Java program from z/OS Unix shell:
Note: In order to create/access files from your home directory /z/zxxxxx in MTM2020 system, you should first be signed up to π MTM2020 and should've finished the challenges till Level 2.4.
We’re going to use the Unix System Services (USS) on z/OS. USS is a Unix Interface within z/OS which you can login through SSH. With VS Code, we’ve got a terminal where we can get into Unix for z/OS and start issuing Unix commands. I already have a root directory under my user ID.
Let's use the touch command to make a new file and name it as HelloWorld.java
A Java program executing from a z/OS UNIX shell can use the same features that you would expect from Java on other platforms:
- java.io package can be used by the Java programs to access z/OS Unix files. Make a note that we can’t use this package to access the traditional z/OS datasets.
- The standard Java java.util package is available in z/OS for normal Java utilities and classes.
- The java.text package can be used for text, date, number and message manipulation.
- The java.net package can be used for TCP/IP communications.
The course also provided info on executing Java programs in z/OS batch mode. A JCL with BPXBATCH utility is used to do this. I've tried and failed in executing a Java program in z/OS batch on the system available via Master the Mainframe 2020.
More info about executing Java programs in z/OS batch can be found π here
Other methods in which we can execute Java programs in z/OS:
The course also hinted several other ways that a Java program can execute than simply from a z/OS UNIX console or batch.
- JAVA applications can execute within CICS Transaction server.
- IMS provides message regions with JVMs that allow Java programs to execute. IMS also provided additional services to allow Java programs to access IMS databases.
- The most interesting method is that DB2 Stored procedures can be written in Java on z/OS. Java programs on z/OS can access database managers such as IMS or DB2 using normal Java JDBC or SQLJ calls. However, the course didn’t provide much info about JDBC/SQLJ calls.
z/OS Specific classes:
One of the most useful tools supplied in the z/OS Java SDK is jzos. This provides Java classes and methods for accessing mainframe resources and information from Java running in batch or z/OS UNIX.
Some of the classes are listed below:
- com.ibm.jzos.AccessMethodServices – This class provides a Java interface to IDCAMS.
- com.ibm.jzos.DfSort – This class provides a Java Interface to sort things out using IBM’s DFSORT.
- To allow Java programs to read/write to z/OS traditional datasets, com.ibm.jzos.RecordReader and com.ibm.jzos.RecordWriter classes can be used.
- com.ibm.jzos.Zfile – This class can access any traditional z/OS dataset including sequential and VSAM datasets.
- com.ibm.jzos.Mvs.JobSubmitter – Allow Java programs to submit z/OS batch jobs.
- jzos also provides a Batch launcher which can act as an alternative to execute Java programs via batch.
Some of the issues π£ faced when programming in Java on z/OS:
This section of the course focused on the issues that arise due to the usage of different encoding shemes π . z/OS operate in EBCDIC (Extended Binary Coded Decimal Interchange Code) and other systems like Windows and Unix operate in ASCII (American Standard Code for Information Interchange). This can cause some confusion when working with Java programs on z/OS.
- All input source to the Java javac compiler is assumed to be encoded in the default character set, EBCDIC for z/OS. Otherwise, the encoding switch of the javac command can be leveraged to specify the character set of the source code (The ISO encoding format for ASCII is ISO8859-1).
- Java Profiles must be in ASCII on all platforms, including z/OS.
- When executing the program, every JVM stores strings and text internally in Unicode (UTF-16). This must be converted when performing any operations around input or output.
- By default, Java assumes that external data is encoded in the default platform encoding. This means, in z/OS, Java program will read input data assuming it is encoded in EBCDIC. Similarly, data written out will be in EBCDIC. If the external file’s encoding is in ASCII, then Dfile.encoding parameter of the Java JVM an be used to specify it as ASCII.
- Java programs can convert between encodings using the getBytes method.
That's all! We've hit the bottom of this post. Share your thoughts π in the Comments section below. thx! π
Very well written blog.
ReplyDelete