Java - A popular programming language
Part Three - Challenge #05

Background:

z/OS includes many of the popular programming languages

The usual suspects (Java, Javascript (node.js), Scala, Python, PHP, Perl, Swift, C++, Go, etc.) frequenting the popular programming lists are all available in the z/OS environment. Any programming language can be ported to the z/OS environment.

A strong preference for any programming language is like claiming to all your friends that you have a best friend. You are likely most familiar with your best friend through years of a positive relationship. While I have many programming language friends, my best friend is REXX. And I know I share my best friend with many others in the industry even though REXX never makes any programming language popularity list.


The challenge situation involves Java - best friend to many

z/OS has many 'modernization' advancements based upon Java and Javascript. The challenge objective is to demonstrate the basics of using Java applied to the z/OS environment.

What you will learn during the next 3 challenges:

  • Java compile using Unix shell prompt
  • Java JVM execution from Unix shell prompt
  • Java compile using JCL
  • Java JVM execution using JCL
  • Java read/write of Unix files
  • Java read/write of MVS data sets
  • Java SQL API

Challenge Description

Many alternatives exist to work with Java in the z/OS environment. Challenge 5 exposes you to a few methods for working with Java. Be aware may ways exist to accomplish the same tasks demonstrated in the challenge.

The challenge will make you aware of a few environmental requirements associated with Java on z/OS. If you have experience with Java in other operating systems, then you are aware Java environmental requirements exist in all operating systems.

Java source can copied between MVS data sets and Unix files using

  • TSO/ISPF commands
  • ISPF Editor
  • Unix commands
  • JCL and System Utilities

Java source edit is possible using

  • ISPF editor
  • OMVS oedit
  • SSH vi
  • Unix sed command

Java compile is possible using

  • Unix commands
  • JCL and System Utilities

Java execution is possible using

  • Unix commands
  • JCL and System Utilities

Java execution can

  • Read and write to MVS data sets
  • Read and write to Unix files
  • Use SQL to read and write to relational DB tables

Challenge:

Copy Java program to MVS partitioned data set member and Unix file
  1. dslist source
  2. edit source
  3. select new empty member using name pgmjava
  4. copy 'ZOS.MTM2019.PUBLIC.P3.SOURCE(PGMJAVA)'
  5. Observe Java source, then F3 or end;return
  6. Enter TSO OMVS to get Unix shell prompt
  7. Enter oedit pgmjava.java - an empty file
  8. copy source(pgmjava)
  9. Enter F3 or end;return - returning you to the Unix shell prompt

Compile and execute Java program using Unix shell prompt

If you do not have a Unix shell prompt, from ISPF command line, enter TSO OMVS. The Unix shell prompt places you in your home directory.

  1. Enter javac pgmjava.java
    Error messages state "not enough storage is available to load DLL"
    TSO OMVS, by default, tries to operate using very few system resources. This is usually not a problem, but as you can see, additional storage is required for this task.
    We can solve this by increasing the storage allocated at login time, but we can also get around this problem by using another connection method, SSH.
  2. Use SSH to access the contest z/OS to compile and execute
      Use SSH workstation client software
       or
      From workstation command prompt, enter ssh z#####@192.86.32.91
      -- Substitute your ID for z#####
      Authenticate with your existing password in lowercase
  3. Enter javac pgmjava.java
      Absence of messages is success
  4. Enter java pgmjava to execute the Java program from the shell prompt

Execute the Java program using JCL
  1. dslist jcl
  2. edit jcl
  3. select new empty member using name pgmjava
  4. copy 'ZOS.MTM2019.PUBLIC.P3.JCL(PGMJAVA)'
  5. Observe JCL, then submit ; =sd ; st to execute JCL and review output

Last task to get full credit for the challenge
  1. dslist jcl
  2. edit jcl member pgmjava
      Java program is writing to JCL DDNAME //STDOUT
      JCL DDNAME //STDOUT redirects output to the JES spool using SYSOUT=*

STDOUT needs to be redirected to write the output message to member #05 in to your P3.OUTPUT partitioned data set.

Change jcl member pgmjava for //STDOUT redirect output to member #05 in to your P3.OUTPUT partitioned data set.

FYI - Score routine can detect the difference between the Java program writing the output vs. you typing the output message into member #05

Need help? Review the JCL from the previous challenge.


What did you just learn?

You are aware Java is able to take advantage of the broad z/OS environment flexibility.

You will learn more in the following challenges.


Next: Challenge #06