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.
Ok…
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!
I could not make the ssh work on my Laptop
C:\Windows\System32>cmd.exe
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\Windows\System32>ssh [email protected]
‘ssh’ is not recognized as an internal or external command,
operable program or batch file.
I could not even Install ssh from my Windows settings
Please healp
Hi Benjamin
Sorry for getting back to you this late. Please follow this guide in order to activate the built-in Windows SSH feature: https://ittutorials.net/microsoft/windows-10/enable-ssh-windows-10-command-prompt/.
Otherwise you can always download https://www.putty.org/ and use that. This requires a lot less work 😉
Goodluck!
-Kevin
K here. Help!
I am stuck in the Unix shell (after the first step in ‘Compile and execute Java program using Unix shell prompt’ and are trying to get in to ssh. I do not think I did it correctly, for now I cannot get out of it. this is a pasted view of my screen. What do I do? how do I get out of here?
IBM
Licensed Material – Property of IBM
5650-ZOS Copyright IBM Corp. 1993, 2017
(C) Copyright Mortice Kern Systems, Inc., 1985, 1996.
(C) Copyright Software Development Group, University of Water
U.S. Government Users Restricted Rights –
Use,duplication or disclosure restricted by
GSA ADP Schedule Contract with IBM Corp.
IBM is a registered trademark of the IBM Corp.
/z/z02688 > oedit pgmjava.java
/z/z02688 > javac pgmjava.java
JVMJ9GC020E -Xms too large for heap
JVMJ9VM015W Initialization error for library j9gc29(2): Faile
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
/z/z02688 > ssh [email protected]
The authenticity of host ‘192.86.32.91 (192.86.32.91)’ can’t
RSA key MD5 fingerprint is 18:6c:f2:06:f5:2c:89:6a:1e:1e:b5:9
Are you sure you want to continue connecting (yes/no)? yes
FOTS2274 Warning: Permanently added ‘192.86.32.91’ (RSA) to t
sts.
FOTS3322 Passwords may not be entered from 3270 terminals
/z/z02688 >
/z/z02688 >
/z/z02688 > end
end: FSUM7351 not found
/z/z02688 >
Ok I just got out of it. Logging on with another computer somehow did the trick. I will try getting into the ssh from the tso command.
Ok, How do I get to the ssh? Please help
Hello, I know this is a very late response, but I used PuTTY for the ssh portion of the challenge, and the way to login to complete that portion is to download and open PuTTY, and when you’re on the configuration screen, type in z#####@192.86.32.91 in the Host name box, replacing the # with your IBM username then click ok; you then need to enter in your password just like you would when logging onto Z/OS, and then you can complete the rest of the ssh portion of the challenge. Hopefully that helped you and good luck.
P.S. Kevin, if you’re reading this and have to redact it for whatever reason, then I understand and I meant no harm, I was only trying to help this person on how to connect and use PuTTY for the ssh portion.
Hi Shirley, thanks for helping! No need to redact anything here, no harm done 🙂
when i browse with “b” #05 part 3, i have seen “.Java says Hello World!.” why this period before and after?
Hi Nilay Paul
That’s odd! There are some broken characters in that string that need to be fixed in the next challenge. Maybe your SDSF editor is on a different viewmode.
Kind regards,
– Kevin
Same issue occurred in my case also…..
I did replaced the code but what after that…..?
Hello,
Actually i am not getting what to replace with what in the last task.
Hi Suraj Burman
Are you talking about challenge #04? Where you need to replace ??? ? with IBM Z? That’s on line 003000, where a specific character needs to be replaced with question marks.
If you’re talking about this challenge and the STDOUT then I mean I copied the DD DSN=&SYS… from Z50087.JCL(SORTCITY) and put it at the STDOUT message. I have replaced P2.OUTPUT(#??) with P3.OUTPUT(#05).
Kind regards,
– Kevin
i have replaced with this code
DD DSN=&SYSUID..P3.OUTPUT(#05),DISP=SHR
but on execution it shows
contained in clist has invalid syntax.
You have maybe duplicated “DD”, otherwise it is should be working.
No I have not duplicated DD.
I am trying several time but execution is not taking place.
Hi Anonymous
Sorry for the late reply! Well, while it’s out there, I have:
2
3
4
5
000002 // PARM='sh java pgmjava'
000003 //STDOUT DD DSN=&SYSUID..P3.OUTPUT(#05),DISP=SHR
000004 //STDERR DD SYSOUT=*
000005 //CEEDUMP DD DUMMY
And that did the trick, are your sure nothing is different?
Kind regards,
– Kevin
Here’s my PGMJAVA output
000001 //JAVAC EXEC PGM=BPXBATCH,REGION=0M,
000002 // PARM=’sh java pgmjava’
000003 //STDOUT DD DSN=&SYSUID..P3.OUTPUT(#05),DISP=SHR
000004 //STDERR DD SYSOUT=*
000005 //CEEDUMP DD DUMMY
Hello Mig
I assume you mean that is your JCL(PGMJAVA)? It looks like an exact copy of mine, it’s very strange that it doesn’t work.
First, DELETE P3.OUTPUT(#05) and execute the script again, see if that helps. After execution, check if there is any error in the output log. I’m not sure if the line command to delete the output is ‘d‘ or ‘p‘.
If it’s not resolved then I would suggest consulting the Slack channel at https://masterthemainframe18.slack.com/ and see if anyone else can help you out. I’m out of ideas.
Kind regards,
– Kevin
is there a difference using ex command or submit ; =sd ; st to execute?
i think this is the problem with the message clist has invalid syntax.
Hi Anonymous
By saying execute I meant “submit ; =sd ; st”, I might have confused you with the execute command that REXX needs. Sorry for that.
Kind regards,
– Kevin
It worked.
Thanks for the guide.