Java! 3 billion devices their best friend! Java is one of the biggest programming languages out there and now we have the chance to work with it on a mainframe.
Note: there might be some encoding issues if you copy and paste the copy commands from my blog into the mainframe. It’s best you copy the paths from the mybluemix website. My quotes are saved differently somehow (angry emoji).
Java – A popular programming language
IBM Master the Mainframe Part Three – Challenge #05
Copy Java program to MVS partitioned data set member and Unix file
Let’s navigate to our Z#####.SOURCE and create a new member using the primary command s pgmjava. Inthere we copy ‘ZOS.MTM2019.PUBLIC.P3.SOURCE(PGMJAVA)’.
Let’s return to the dslist by pressing F3. As primary command we enter TSO OMVS and enter oedit pgmjava.java.
Once in edit mode we copy source(pgmjava) and return using F3.
Compile and execute Java program using Unix shell prompt
From the OMVS shell I enter javac pgmjava.java as command. There might be a message, but we can ignore that one.
So, we now have to connect to the workstation via SSH. Good lord, yeah, let me try.
Oof, (sweaty palms emoji thingy). I got in. RIGHTCLICK to paste something in the command prompt, I used CTRL+V and felt stupid.
Now it compiled correctly! Does it suddenly have java because it’s accessed via CMD? WHAT.
YES I PRESSED CTRL+V AGAIN. OOPSIE. Let’s execute using java pgmjava. And I saw the hello world message! YESS! Enter the command exit to safely terminate the SSH connection.
Execute the Java program using JCL
Now in Z#####.JCL we create a new member pgmjava and copy ‘ZOS.MTM2019.PUBLIC.P3.JCL(PGMJAVA)’ into it. After that, let’s submit ; =sd ; st and check the output.
Last task to get full credit for the challenge
We need to change STDOUT in jcl member pgmjava and redirect output to member #05 in to our P3.OUTPUT partitioned data set.
I honestly don’t know what I need to do here, so I’ll just copy and paste the code after //SORTOUT in Z50087.JCL(SORTCITY) and change it to P3.OUTPUT(#05). I’ll take my chances! If you’re unsure if you have the correct thing, just compare our things’ length. If you’re as long as mine, you’ve got it.
Let’s execute! No errors so far. Let me check P3.OUTPUT(#05).
Done! All good! Let’s continue to challenge #06!