MC Press Online
Welcome to the MC Press Online!
Need help with our eBooks?
Contact PublishersRow.com
Click here, to go to our main store

  MC Press Online eBookStore  

Java for RPG Programmers
preview of book Java for RPG Programmers
text of book Java for RPG Programmers

Java for RPG Programmers

Authors:
Publisher: MC Press Online
Publication Date: December 2006
Subject: Computer: Programming
Category: Programming
Number of Pages: 823

Free Preview    Email to Friend   Add to wish list
 Available as: (for format`s description click on its name)
Individual E-Version (PDF) Individual E-Version (PDF) ISBN: 978-1-931182-29-4  
$54.39
 
 Reg.: $
79.99 per N pages
 You Save: 
$25.60 (32%)
 Online  Open CopyPrint    
all time
Printed Edition   see MC Press Online    
About this title
PLEASE NOTE: The contents of the CD that accompanies the print edition of this book are available via Web download. See the Contents tab at www.mc-store.com/5234.html.

The role of Java™ continues to grow, as does the importance of learning this critical language. RPG certainly won't disappear any time soon, but more and more businesses are including the Web in their application mix…and that means more Java. As a result, wise RPG programmers will want to add Java to their programming toolkit. And while learning Java might seem daunting at first, with the right help it's easier than you think.

Written by System i™ experts Phil Coulthard and George Farr, this book teaches Java from an RPG programmer's perspective. Phil and George have been immersed in IBM® RPG development at the IBM Toronto laboratory for years. But they are also key developers in the IBM Java platform and tools. This gives them the perfect combination of skills and expertise to explain the practical use of Java for System i development.

Whether describing a term, a concept, or a side-by-side code example, their carefully constructed path through Java from an RPG point of view is the perfect solution for RPG programmers, who sometimes struggle with object-oriented programming concepts. Join the authors as they explore the Java language step by step: syntax, structured operations, data types, string manipulation, database access, and more. This book will gently—yet comprehensively—teach you the Java language and core Java-supplied functionality. Best of all, you'll learn Java by comparing it to the language you know best: RPG.

As a programmer or development manager who wants to stay on the cutting edge of your career, you should learn to use and understand Java and its promise. If you are an architect, it is even more important to know Java, particularly when and where to use it. Or perhaps more importantly...when not use it.

You already mastered RPG. Leverage that investment and learn Java today!

With Java for RPG Programmers, Third Edition, you will:
  • Understand the various roles of Java in today's applications
  • Learn the core Java language
  • Discover how to use the Java Development Kit (JDK)
  • Master the basics of object-oriented (OO) programming
  • Explore Java applications, applets, servlets, JavaBeans™, Enterprise JavaBeans™, as well as Java Swing for graphical user interfaces
About authors
Phil Coulthard
Phil Coulthard is the lead architect for AS/400 application development projects at the IBM Toronto Laboratory. He has worked as a developer, team leader, manager, and general advocate of AS/400 application developments since 1986. An author of many industry magazine articles and a frequent speaker at AS/400 conferences, Phil currently resides in Aurora, Ontario.

George Farr
George N. Farr is the technical development manager for RPG IV as well as VisualAge for RPG products. He has held the position of developer, team leader, and development manager and has been an AS/400 planner and architect since 1985. He is a frequent speaker at AS/400 conferences and user groups worldwide and has written many industry magazine articles and books, including ILE: A First Look and RPG IV by Example. He currently resides in Toronto, Canada.

Contents
CONTENTS
Chapter 1: THE WORLD OF JAVA
WHAT IS JAVA?
WHAT ABOUT THAT OO THING?
WHY THE HYPE?
  The Name
  The Internet
  Portability
  Accessibility
THE ROLES OF JAVA
THE HOUSE OF JAVA
JAVA BYTECODE
JAVA: THE LANGUAGE
THE INTERNET, HTML, AND JAVA APPLETS
  HTML as an Internet user-interface language
  Java as an Internet user-interface language
JAVA APPLICATIONS
JAVASCRIPT
JAVASERVER PAGES
ENTERPRISE JAVABEANS
JAVA VERSUS RPG
SUMMARY
  References

Chapter 2: THE JAVA ONION
RPG IV VERSUS RPG III APPLICATIONS
THE OUTER SKIN: RPG VERSUS JAVA
  RPG's outer skin
  Java's outer skin
  Compiling RPG
  Compiling Java
  About RPG IV procedures
  RPG IV flow of control
  About Java methods
  Java's flow of control
COMPARING ANATOMIES
  RPG syntax
  Prototyping RPG procedures
  Defining RPG procedure
  Calling RPG procedures
JAVA SYNTAX
  Java class syntax
  Java variable syntax
  Java method syntax
  An example of a Java class
  Getter and setter methods in Java
ALLOCATING MEMORY IN RPG IV
USING JAVA CLASSES
  Accessing methods
  Accessing variables
  This is special
  Java overload! Java overload!
STATIC MEMBERS
  RPG static fields
  Java static variables
  Java static methods
CONSOLE-ATION•
  Calling a Java program: The “main” method
  Command-line parameters in RPG
  Command-line parameters in Java
  Writing to the command line in RPG
  Writing to the command line in Java
  Class constructors in Java
CODE REUSE AND DISTRIBUTION
  Distributing reusable RPG code as service programs
  Java code reuse through packages
JAVA ACCESSOR RIGHTS
SUMMARY

Chapter 3: JAVA'S LANGUAGE AND SYNTAX
I WANT TO BE FREE! THE JAVA BASICS
COMMENTS
  Java comments
  JavaDoc comments
VARIABLE NAMING
  The naming syntax for fields and variables
  Keywords
COMPARING ANATOMIES
  The anatomy of an RPG program
  The anatomy of a Java Class
STATEMENTS
  The expression statement
  The block statement
  The empty statement
  The labeled statement
EXPRESSIONS AND OPERATORS
  Computational expressions
  Fetch expressions
OTHER MATHEMATICAL FUNCTIONS
SUMMARY

Chapter 4: STRUCTURED OPERATIONS AND STATEMENTS
ALTERNATE PATHS: DECISION STRUCTURES
  If, then what? Else, of course
  Too many IFs? Time to switch!
  The conditional operator, ?:
  Loop structures—They get around
  Going “for” a loop—Just “do” it
  A FOR loop in RPG—Yes, in RPG
  Looping for a while
  Looping until done
TRANSFER STRUCTURES
  If you continue, I will need a break
  Go to where?•
  Return to caller
SUMMARY

Chapter 5: DATA TYPES AND VARIABLES
A REVIEW OF RPG TYPES
AN INTRODUCTION TO JAVA TYPES
DATA DECLARATION
  Defining fields in RPG
  Defining variables in Java
VARIABLE SCOPE, LIFETIME, AND EXTERNAL ACCESS
  Variable scope
  Variable lifetime
  Variable external access
  Variables: An example
LITERALS BY DATA TYPE
NUMERIC DATA TYPE RANGES
FLOAT VERSUS PACKED
THE BOOLEAN DATA TYPE
CASTING AND NUMERIC CONVERSIONS
JAVA DATA-TYPE CLASS WRAPPERS
SUMMARY

Chapter 6: ARRAYS AND VECTORS
OBJECT REFERENCE OPERATORS
ARRAYS
  Declaring arrays
  Creating or instantiating arrays
  Compile-time initialization of arrays
  Runtime initialization of arrays
  Initializing multi-dimensional arrays
  Arrays are objects
  Pre-runtime arrays in RPG
  Unbalanced arrays
  Arrays of objects
  Helper methods for arrays
VECTORS
  The Registration class
  The AttendeeList Class
  The Attendee class
  Simulating vectors in RPG
HASHTABLES
PARAMETER PASSING
  Parameter passing in RPG IV
  Using arrays instead of primitives for simulated pass-by-reference
SUMMARY

Chapter 7: STRING MANIPULATION
JAVA STRING BASICS AND PITFALLS
STRINGS IN RPG
STRING MANIPULATION
  Concatenation
  Substrings
  Searching for a substring
  Trimming blanks
  Determining string lengths
  Translating characters
  Translating case
  Checking for characters
PERFORMANCE CONSIDERATIONS: THE STRINGBUFFER CLASS
IMPLEMENTING TRIMR AND TRIML IN JAVA
TOKENIZING STRINGS: THE STRINGTOKENIZER CLASS
THE STRING CLASS: MORE METHODS
SUMMARY

Chapter 8: DATE AND TIME MANIPULATION
RPG IV DATE AND TIME ENHANCEMENTS
JAVA DATE AND TIME SUPPORT
RAW TIME
GET ME A DATE, AND GIVE ME THE TIME!
DATE AND TIME MANIPULATION
  Date/time math and duration
  Comparing dates•
  Extracting parts of a date or time
FORMATTING DATE FIELDS
FORMATTING TIME FIELDS•
THE DEFAULT FORMATTER
TESTING DATE AND TIME
LOOK BEFORE YOU LEAP
TIME ZONES
SUMMARY

Chapter 9: AN OBJECT ORIENTATION
THE THREE TENETS OF OO
  Encapsulation
  Inheritance
  Polymorphism
INHERITING MORE OR LESS
  Preventing inheritance
  Enforcing inheritance
THE FACTORY METHOD-DESIGN PATTERN
INTERFACES
  Interfaces versus inheritance
  Interfaces are callbacks
  Interfaces and constants
  Java-supplied interface examples
O2O—OBJECT TO OBJECT: CASTING OBJECTS
COMMON METHODS TO OVERRIDE
THE OO WAY OF LIFE
  In search of objects
  OO design tips
SUMMARY
REFERENCES

Chapter 10: EXCEPTIONS
SYSTEM I EXCEPTION MODEL OVERVIEW
  The OPM exception model
  The ILE exception model
  RPG III exception-handling
  ILE RPG (RPG IV) exception-handling
  New MONITOR operation in RPG V5R1
EXCEPTIONS IN JAVA
  The Java exception model at a glance
  Exception objects in Java
  Searching Java documentation for classes
  Sending Java exceptions with the throw operator
  Monitoring for Java exceptions with try/catch blocks
SUMMARY

Chapter 11: THREADS
SYNCHRONOUS VERSUS ASYNCHRONOUS
THREADS VERSUS JOBS
CALLING A METHOD ASYNCHRONOUSLY: SPAWNING THREADS
  Calling without using threads
  Using threads, option 1: The extends thread
  Using threads, option 2: implements Runnable
STOPPING A THREAD
  Stopping multiple threads: The ThreadGroups class
  Ending programs with Java running threads
DAEMON THREADS
THINKING ASYNCHRONOUS—DANGER LURKS...
  The role of threads in a complex multi-user application
  How single objects can have multiple threads of execution
  Multithreaded danger: An inventory example
  The solution: Synchronizing asynchronous execution
  Fine-grained synchronization
  Threaded application design alternatives
MORE ON THE SYNCHRONIZED KEYWORD
  Synchronizing producer/consumer relationships with wait/notify
  Deadly embrace
THREAD PRIORITIES
LOOSE THREADS
TIMING THREADED APPLICATIONS
SUMMARY

Chapter 12: USER INTERFACE
USER INTERFACES IN RPG IV
USER INTERFACES IN JAVA: OPTIONS, OPTIONS, OPTIONS
JAVA GUI
AN OVERVIEW OF JAVA SWING
BASIC GUI COMPONENTS IN JAVA
  Common inherited methods
  Common non-inherited methods
  Model view controller
  Events
CONTAINERS: JFRAMES, JDIALOGS, AND JPANELS
  Adding components to containers: Layout managers
  Nesting layout managers: The JPanel class
  A simple form class
EFFECTIVE USE OF JTextFields
  Component sizing and layout managers
  Restricting input in a JTextField
MENU BARS AND POP-UPS
ADVANCED SWING FUNCTIONALITY
  Default push button
  Toolbars
  Actions
  Multiple-document interface
  More components
  More containers
  Look and feel
  Predefined dialogs
  Message and simple input dialogs
APPLETS VERSUS APPLICATIONS
  Applets and Swing
TRANSLATION-READY USING RESOURCE BUNDLES
  Locales
  Translated strings—Resource bundles
SUMMARY

Chapter 13: DATABASE ACCESS
DATABASE ACCESS IN RPG IV
RPG DATABASE ACCESS UNDER COMMITMENT CONTROL
ACCESSING DATA WITH SQL
  Interactive SQL versus embedded SQL
  Static SQL versus dynamic SQL
  Dynamic SQL versus CLI APIs
  Local versus distributed SQL
  SQL terminology
  SQL languages: DDL versus DML
  What you need for SQL on the AS/400
WHY THE INTRODUCTION TO SQL?
ACCESSING DATA WITH JAVA
JDBC DRIVERS FOR DB2/400
JAVA JDBC PROGRAMMING
  Steps 1 and 2: Registering and connecting
  Step 3: Creating SQL statement objects
  Step 4: Running the SQL statements
  Step 5: Retrieving the information in result sets
  Step 6: Close, close, close
  More on data types
  Null-value considerations in JDBC
  Commitment control in JDBC
  Retrieving database metadata in JDBC
THE GOOD STUFF: STORED PROCEDURES, TRIGGERS, AND RI
STORED PROCEDURE CALLS IN JDBC
WHAT'S NEW IN JDBC 2.0
  Datatype enhancements
  ResultSet enhancements
  Something new: Batch updates
  Optional JDBC 2.0 enhancements
WHAT'S NEW IN JDBC 3.0
EMBEDDED SQL IN JAVA: SQLJ
  Writing embedded SQL in Java
  Preparing and compiling embedded SQL in Java
SUMMARY
REFERENCES

Chapter 14: MORE JAVA
INNER CLASSES
ANONYMOUS INNER CLASSES
STATIC INITIALIZERS
JAVA NATIVE INTERFACE (JNI)
JAVA REMOTE METHOD INVOCATION (RMI)
JAVA OBJECT SERIALIZATION
J2SE 5.0 LANGUAGE CHANGES
  Generics
  Enhanced for Loop
  Autoboxing/Unboxing
  Enumerations
  Variable Arguments List
  Static Import
  Annotations
JAVA-SUPPLIED PACKAGES
COMMON “HOW DO I?” QUESTIONS
  How do I determine the working directory?
  How do I change the working directory?
  How do I list files and directories?
  How do I list drives?
  How do I create a directory?
  How do I create or open a flat file and write to it?
  How do I read a flat file?
  How do I call another program or command?
  How do I save and restore user-profile information?
JAVABEANS
  Properties
  Bound properties
  Events
  Serializing beans
  The BeanInfo class
  Beans and tools
  More beans
NEXT STEPS: OF SERVLETS, JSPS, EJBS, AND MORE
SUMMARY

APPENDIX A
INSTALLING THE COMPONENTS
THE ISERIES IBM DEVELOPER KIT FOR JAVA
  Using the Integrated File System and QShell Interpreter
  Working with Java on OS/400
  Setting your classpath in QShell
  Using CL commands for Java and the Java Transformer
ISERIES IBM TOOLBOX FOR JAVA
  Getting the iSeries IBM Toolbox for Java classes
  Using the iSeries IBM Toolbox for Java classes
  The CommandCall class
  The ProgramCall class
  PCML for easy calling of programs and service programs
  The DataQueue class
  Record-level database access
OTHER AS/400 TOOLBOX FOR JAVA FUNCTIONALITY

APPENDIX B
RPG CALLING JAVA
  Mapping data types
  Java exceptions when calling Java from RPG
  Java Virtual Machine considerations
  Classpath considerations
CALLING RPG PROCEDURES AS RPG NATIVE METHODS FROM JAVA
FINALLY

Appendix C: OBTAINING THE CODE SAMPLES

ABOUT THE AUTHORS

INDEX
Related titles
Advanced, Integrated RPGAdvanced, Integrated RPG
Eclipse: Step by StepEclipse: Step by Step
Programming in RPG IVProgramming in RPG IV
IBM i Programmer's Guide to PHP, TheIBM i Programmer's Guide to PHP, The
 
  Special Offer Code  
Enter your Special Offer Code here:
  Search for  

  Our Products  
Browse all »»
From Idea to Print, Chapter 06: Using Tables, Artwork, and Sidebars
IBM Business Analytics and Cloud Computing
Eclipse: Step by Step

If download option is selected, Adobe Acrobat 5.0 or later is required to read our e-books*


Windows PC, Mac OS9/OSX, and Linux