®

IBM Software Group

Java and z/OS (and RDz)

Jon Sayles – jsayles@us..com

© 2016 IBM Corporation IBM Software Group | Rational software Merrill Class

. They’ll have RDz exposure . Terms & Concepts & Vocabulary Remove fear of Java Analogies – Procedural vocabulary 20 – 30 students - mix of young + old (mostly old) dudes . Call COBOL from Java Java doesn’t create an .exe Objects . z/OS Java Standard z/OS environment JCL – pointing to Unix Aware of JVM – can call COBOL http://www.s390java.com/index.htm IBM Software Group | Rational software Trademarks Trademarks

The following are trademarks of the International Business Machines Corporation in the United States and/or other countries. For a complete list of IBM Trademarks, see www.ibm.com/legal/copytrade.shtml: AS/400, DBE, e-business logo, ESCO, eServer, FICON, IBM, IBM Logo, iSeries, MVS, OS/390, pSeries, RS/6000, S/30, VM/ESA, VSE/ESA, Websphere, xSeries, z/OS, zSeries, z/VM

The following are trademarks or registered trademarks of other companies

Lotus, Notes, and Domino are trademarks or registered trademarks of Lotus Development Corporation Java and all Java-related trademarks and logos are trademarks of Sun Microsystems, Inc., in the United States and other countries LINUX is a registered trademark of Linux Torvalds UNIX is a registered trademark of The Open Group in the United States and other countries. Microsoft, Windows and Windows NT are registered trademarks of Microsoft Corporation. SET and Secure Electronic Transaction are trademarks owned by SET Secure Electronic Transaction LLC. Intel is a registered trademark of Intel Corporation * All other products may be trademarks or registered trademarks of their respective companies.

NOTES:

Performance is in Internal Throughput Rate (ITR) ratio based on measurements and projections using standard IBM benchmarks in a controlled environment. The actual throughput that any user will experience will vary depending upon considerations such as the amount of multiprogramming in the user's job stream, the I/O configuration, the storage configuration, and the workload processed. Therefore, no assurance can be given that an individual user will achieve throughput improvements equivalent to the performance ratios stated here.

IBM hardware products are manufactured from new parts, or new and serviceable used parts. Regardless, our warranty terms apply.

All customer examples cited or described in this presentation are presented as illustrations of the manner in which some customers have used IBM products and the results they may have achieved. Actual environmental costs and performance characteristics will vary depending on individual customer configurations and conditions.

This publication was produced in the United States. IBM may not offer the products, services or features discussed in this document in other countries, and the information may be subject to change without notice. Consult your local IBM business contact for information on the product or services available in your area.

All statements regarding IBM's future direction and intent are subject to change or withdrawal without notice, and represent goals and objectives only.

Information about non-IBM products is obtained from the manufacturers of those products or their published announcements. IBM has not tested those products and cannot confirm the performance, compatibility, or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products.

Prices subject to change without notice. Contact your IBM representative or Business Partner for the most current pricing in your geography.

References in this document to IBM products or services do not imply that IBM intends to make them available in every country.

Any proposed use of claims in this presentation outside of the United States must be reviewed by local IBM country counsel prior to such use.

The information could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new editions of the publication. IBM may make improvements and/or changes in the product(s) and/or the program(s) described in this publication at any time without notice.

Any references in this information to non-IBM Web sites are provided for convenience only and do not in any manner serve as an endorsement of those Web sites. The materials at those Web sites are not part of the materials for this IBM product and use of those Web sites is at your own risk.

3 IBM Software Group | Rational software

Java and the software world IBM Software Group | Rational software Why Learn Java? . Common code across platforms Java code can be reused in CICS, WAS, Batch, and other application program platforms . Modern, powerful, easily available developers/tools Allow to extend usage of the mainframe while using a more modern programming language and tooling Most of today’s investment by the world’s primary software vendors involves Java . Even things like ODM, Business Rules, etc. wrap around Java . Large code base of pre-built applications, tools, frameworks and design patterns . Legacy of agile development processes (JUnit, etc.) replacing Waterfall lif . You’re not retiring next week . Cost, cost, cost: Java can be run more cheaply than COBOL or other traditional mainframe languages when using a zAAP processor IBM Software Group | Rational software Java == “Write once…run anywhere”

The key is the “isolation of program from hardware …” IBM Software Group | Rational software Java Bytecode – Isolating programs from hardware IBM Software Group | Rational software Java Programs  Bytecode  the Java Virtual Machine

1. 2.

1. You code in a file named: Xxxxx.java Java Virtual Machine

2. You compile to a Java class: Xxxxx.class

3. You run your program on any supported java platform - using a Java 3. Virtual Machine (a JVM) IBM Software Group | Rational software Java Tools … RDz – as a Java SDK IBM Software Group | Rational software

Java and procedural programming constructs IBM Software Group | Rational software Java  COBOL – Development similarities

. Java source file  COBOL source file . Java class file  COBOL module . Java bytecode  COBOL “object module” (COBOL Compiler output) . Java virtual machine  the z/OS operating system . There are many many, many additional parallels between Java and COBOL – especially at the language level IBM Software Group | Rational software Java  COBOL – Programming similarities (1 of 2) IBM Software Group | Rational software Java  COBOL – Programming similarities (2 of 2)

• Package  Library • Class  Module • Method  Subroutine • Variables  Variables • Statements  Statements: Math, I/O (QSAM/VSAM), Conditionals, Branching, Database (DB2, IMS, etc.), CICS, IMS TM, Display, U.I. – etc. IBM Software Group | Rational software

How to write and test Java using RDz IBM Software Group | Rational software Java development and RDz Perspectives . COBOL tools are in the z/OS Projects Perspective IBM Software Group | Rational software Java development and RDz Perspectives . Java tools are in the Java Perspective IBM Software Group | Rational software Java development using RDz . Open the Java Perspective:  Package Explorer view . Create a Java Project . Create a Package . Create a HelloWorld Class . Run as a Java Application . Set Break points . Step through code to branch to the method . Debug as Java application . Port the Package to z/OS (UNIX File System) . Drag & Drop a file to UNIX . Search in USS IBM Software Group | Rational software Open the Java Perspective

This is the Java Perspective … (different Views will display) IBM Software Group | Rational software Create a Project, Package and Class

. Right-click inside of the Package Explorer View and select: New > Java Project Name the Project HelloWorldProject and click Finish . Right-click over the HelloWorld Project and select: New > Package Name the Package: helloWorldPackage and click Finish (note - lower case “h”) . Right-click over the helloWorldPackage and select: New > Class Name the Class: HelloWorld Click Finish

Your new java Class file IBM Software Group | Rational software Your first example Java Class (code)

. From the slide notes, copy and paste the following code into the HelloWorld Class . Press Ctrl/S to save your work Note that if you get any syntax errors, check the package name or redo this paste step

The code is embedded in this slide’s Notes area IBM Software Group | Rational software Run as a Java Application . From the Package Explorer; expand your project > package > class . Select HelloWorld.java and Run it As a Java Application  Note the System.out.println results in the Console view. IBM Software Group | Rational software Debug as a Java Application . Double-click your mouse over the left-hand frame of your source file, to create 3 breakpoints on the System.out.println statements (as shown in the screen capture) . From the Package Explorer; expand your project > package > class . Select HelloWorld.java and Debug it As a Java Application  Note; You will be prompted to switch to the Debug Perspective … do so

 IBM Software Group | Rational software Debugging Java . From the Debug toolbar  Use Step into - to run a statement, and step into a called method  Use Step return - to run the remaining code in a called method, returning to the Next Sequential instruction  Use Step over - to run a statement - and run through all of the code in a called method  Use Resume - to run to the next breakpoint, or to normal EOJ  Use Terminate - to halt your debug session

You can alter variable values on the fly IBM Software Group | Rational software Export to Remote JAR file - 1 of 2 . Return to the Java Perspective . Right-click over your helloWorldPackage, select Export . Type rem in the filter, select Remote JAR file and press Next >

. Check the box for your Project

. Click Browse… IBM Software Group | Rational software Export to Remote JAR file - 2 of 2 . Expand your named Connection to z/OS  . Scroll down inside of the Unix System Services directories until you see: u  . Name the Archive file . Click OK . Click Finish - Note that you need R/W authority in UNIX IBM Software Group | Rational software Drag & Drop onto the UNIX File System . Just like with MVS files, you may drag & drop (or copy & paste) files and folders from your PC up to UNIX on z/OS

. Note that you need R/W authority to Copy/Paste files into the z/OS UNIX File System IBM Software Group | Rational software Search in z/OS UNIX for your exported Java source . Return to the z/OS Projects Perspective . From Remote Systems . Expand z/OS UNIX Files . Scroll down inside the directories until you see: u  . Right-click over your TSO ID and select Search… . Search for: hello IBM Software Group | Rational software Search Results

. You should be able to open a Java file But not a jar file IBM Software Group | Rational software Links

. Java - http://www.ibm.com/servers/resources/sdkguide.zos.pdf . JzOS - http://www.ibm.com/servers/eserver/zseries/software/java/ . RDz - http://www.ibm.com/software/awdtools/rdz/ . RDz Hub - http://www.ibm.com/software/rational/cafe/community/cobol/rdz?view=overview . Writing Java applications for z/OS – White Paper http://www.ibm.com/developerworks/websphere/library/techarticles/0703_england/ 0703_england.html . Porting Java applications to z/OS – White Paper http://www.ibm.com/developerworks/rational/library/10/portingjavaapplicationstozo s/index.html IBM Software Group | Rational software CICS Application Architecture Java can go here!

CICS TS Transaction

3270 or Integration Business Data Client HTML logic logic access Presentation P I B D

§ Best practice in CICS application design is to separate key elements of the application, in particular:  Presentation logic eg. - 3270, HTML, XML  Integration or aggregation logic - Menu, router, tooling  Business logic - Reusable component  Data access logic - VSAM, DB2, IMS, … § Provides a framework for reuse and facilitates separation of concerns, clear interfaces, ownership, and optimization § Allows callable business logic – parameters passed via COMMAREA § Can use Java for any of the programs above, but JCICS does not support BMS

30 IBM Software Group | Rational software Java and IMS – Environments DB2 CICS WebSphere

DLI IMS Java Database App View DLI IMS Java Database App View

JDBC / SQL A p p DLI Stored IMS Java Database JDBC / SQL App DB A View p p

Base DB

JDBC / SQL JNI A Base p p CEETDLI Interface JCICS DB Procedure EJB JNI Base CEETDLI Interface

JNI

CEETDLI Interface Java Virtual Machine Java Virtual Machine Java Virtual Machine IMS

DLI DLI IMS Java IMS Java Database Database App App View View

JDBC / SQL JDBC / SQL A A p p p p

DB DB

M B I Base Base JNI JNI ODBA P M F CEETDLI Interface CEETDLI Interface P P P JMP JBP DRA Java Virtual Machine IMS DB

31 IBM Software Group | Rational software Java Batch

Note: There are 5 or 6 alternative architectures for running Java Batch

http://www.ibm.com/developerworks/systems/library/es-java-batchz.html IBM Software Group | Rational software Additional program

From the slide Notes, select and copy all of the Java code . From RDz: Create a new Class in your helloWorldPackage Name the Class HelloWorld2 Read through the code, and save your Java file. . Run . Set breakpoints . Debug

. What does this program do? . How does it do what it does?  What are the programming patterns?  Have you ever done anything like this in COBOL? IBM Software Group | Rational software AMS Method/Example

A class that provides a Java interface to z/OS Access Method Services (IDCAMS). Output from IDCAMS (DD SYSPRINT) is redirected by default to a String (getOutputLines()). The method setOutputDDName(String) may be used before execute() to direct IDCAMS output to a pre-allocated DDNAME.

Example: LISTC output directed to outputLines String buffer.

AccessMethodServices ams = new AccessMethodServices(); ams.addInputLine("LISTC LEVEL(ACCTING)"); int rc = ams.execute(); System.out.println("IDCAMS output:"); System.out.println(ams.getOutputLines());

Example: LISTC output directed to temporary dataset

String ddname = ZFile.allocDummyDDName(); ZFile.bpxwdyn("alloc fi(" + ddname + ") da(&&IDTEMP) new delete reuse msg(2)"); AccessMethodServices ams = new AccessMethodServices(); ams.setOutputDDName(ddname); ams.addInputLine("LISTC LEVEL(BILLING)"); int rc = ams.execute(); ... ZFile.bpxwdyn("free fi(" + ddname + ") msg(2)");