370 Building Java Applications for the iSeries Server with VisualAge for Java 3.5
Figure 9-32 Host application successful start
We are now ready to run the client application. Both the registry and the host application are
started.
After executing the client application, perform the following tasks:
1. Enter the iSeries system name, user ID, and password. Click Connect.
2. After the Connected to AS/400 message appears, complete the following steps:
a. Enter a part (item) number and click the Get Part button. Valid numbers are 12301
through 12350.
b. Click the Get All Parts button to display all the records in a table.
9.5 Moving the Order Entry server application to Java
So far, we have shown you how to move the user interface for the Order Entry application to a
client PC using Java. We have demonstrated how to do this while reusing much of the existing
RPG application. Now, we are ready to replace the RPG application with a Java version. The
primary benefit of this is to gain easier maintenance and portability of our application.
Next, we migrate the Order Entry application to Java on iSeries. We use the Java remote
method invocation interface to allow the client Java program to interface with the server Java
code. Figure 9-33 shows the new design.
Java Shell Display
initialize:new
Main: Attempting to register JDBCRmi
Main: Successfully registered with the RMI
===>
F3=Exit F6=Print F9=Retrieve F12=Exit
F13=Clear F17=Top F18=Bottom F21=CL command entry
Chapter 9. Moving the server application to Java 371
Figure 9-33 Java client/Java server Order Entry application
This section explains the Java code that is necessary to replace the RPG Order Entry
application. We discuss two techniques: how to use record-level access and how to use
JDBC. We also discuss the changes that are required for the client code.
There are three approaches to creating Java on iSeries for the Order Entry application:
򐂰 We can simply create a procedural Java program and make all variables and methods
public. This is the most straightforward way of moving to Java, but it does not take
advantage of any of the object-oriented constructs, such as encapsulation.
򐂰 We can completely redesign the application to be fully object-oriented. This involves
creating classes to encapsulate all of the files that are used, a class to hide the data queue
implementation, and classes to describe an order and a customer.
򐂰 We can compromise and use object-oriented constructs where it seems sensible to do so
and still use a somewhat procedural coding style for the primary methods.
We have chosen to take the third approach, because it seems to be easier to understand as a
first step in moving to Java. We use classes to describe the Order Entry application and the
order itself. We also hide the internal implementation of the Order Entry class.

Get Building Java Applications for the iSeries Server with VisualAge for Java 3.5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.