If you’re a Java developer in an iSeries (formerly AS/400) shop and you need to access resources on a PC, you can use JTOpen to get the job done. On the flipside, if you are an RPG programmer tasked with reimplementing your console application in the client environment, JTOpen can help you, too—assuming that you have some familiarity with Java.

Since the late 90s, IBM has been working on incorporating Java into the iSeries operating system. One of the tool sets it made available to developers was the IBM Toolbox for Java. This is a licensed program you can order for your iSeries that allows you to run Java programs directly from a command line and/or create client/server applications to access iSeries resources. In May 2000, IBM “open sourced” a subset of this licensed program and dubbed it JTOpen.

What is it?
JTOpen is a set of Java classes written to access various iSeries resources. Until JTOpen, the only avenues for accessing these resources were via client access VB and VC++ APIs or using a native console language, such as RPG, C++, or COBOL on the iSeries.

Since this toolbox is written in Java, you can write applications that access these resources for any OS that supports Java, including AIX, OS/400, Linux, Network Station, OS/2, Solaris, and Windows.

How does it work?
JTOpen’s collection of classes allows access to many inherent functions of the iSeries server that you can use in your applications. Below is a list of the classes that I believe are worth mentioning.

Access classes
These are the core classes that represent the resources that you’ll want to access on the iSeries. To name a few, these include:

  • ·        AS/400—Manages sign-on information, creates and maintains socket connections, and sends and receives data
  • ·        Command call—Runs iSeries batch commands
  • ·        Connection pool—Manages a pool of AS/400 objects, which is used to share connections and manage the number of connections a user can have to an iSeries server
  • ·        Data area—Creates, accesses, and deletes data areas
  • ·        Data conversion and description—Converts and handles data and describes the record format of a buffer of data
  • ·        Data queues—Creates, accesses, changes, and deletes data queues
  • ·        Messages—Accesses messages and message queues on the iSeries system
  • ·        Users and groups—Accesses iSeries users and groups

ReportWriter classes
These classes (in the processor package) enable you to generate formatted reports using information your application gathers from XML source data, Java servlets, and JavaServer Pages (JSP). There are also Context classes that allow you to take information from the iSeries machine and convert it to a familiar format. These classes enable you to create PCL documents, allowing you to print directly to a printer and to PDF documents.

HTML classes
The HTML classes assist you in:

  • ·        Setting up forms and tables for HTML pages.
  • ·        Aligning text.
  • ·        Working with a variety of HTML tags.
  • ·        Altering the language and direction of text.
  • ·        Creating ordered and unordered lists.
  • ·        Creating file lists and HTML hierarchical trees (and the elements within).
  • ·        Adding tag attributes not already defined in the HTML classes, such as bgcolor and style attributes.

You can incorporate these classes into your servlets and JSP to allow for dynamic creation of HTML.

Utility classes
Several classes aid the use of the toolbox. These include:

  • ·        AS400ToolboxInstaller—This allows you to install and update IBM Toolbox for Java classes on the client. This function is available both as a Java program and as an application programming interface (API).
  • ·        AS400ToolboxJarMaker—This generates a faster-loading IBM Toolbox for Java JAR file by creating a smaller JAR file from a larger one or by selectively unzipping a JAR file to gain access to the individual content files.
  • ·        CommandPrompter—This prompts for the parameter on a given command. CommandPrompter offers functionality that is similar to the iSeries CL command prompt (pressing [F4]) and the same as the Management Central command prompt.
  • ·        RunJavaApplication and VrunJavaApplication—These allow you to run a Java program on an iSeries server from a command line prompt.
  • ·        Jping—This allows you to query a server to find out which services are active. You can also specify whether you want to ping the SSL ports.

Visual access classes
JTOpen offers classes that are visual representations of the access classes for use in GUI applications and applets, as shown below:

  • ·        Command call
  • ·        Data queues
  • ·        Error events
  • ·        Integrated file system
  • ·        JDBC
  • ·        Jobs
  • ·        Messages
  • ·        Permission
  • ·        Print (including the spooled file viewer)
  • ·        ProgramCall and ProgramParameter
  • ·        Record-level access
  • ·        Resource lists
  • ·        System status
  • ·        System values

Most of the visual access classes are created as JavaBeans so they are easily plugged into many of the popular IDEs that contain a GUI editor. The code in Listing A is an example that was created using the popular JBuilder IDE. Listing A uses two classes, VIFSDirectory and AS400ExplorerPane. The VIFSDirectory is a resource that visually represents a directory in the integrated file system (commonly referred to as the IFS) for use in AS400Panes. The AS400ExplorerPane is a type of AS400Pane that combines an AS400TreePane and AS400DetailsPane so that the resource selected (VIFSDirectory) in the tree is presented in the details, as shown in Figure A.

Figure A

How do I use it?
Listing B offers a code example that shows how easy it is to use the CommandCall object to send a command to the AS/400 in a Java application or applet.

If you have to access an iSeries machine from your program, and you’re using Java, this toolbox is definitely what you need. I recommend that you download the toolbox and take a look at the documentation. The documentation can help you get started building Java applications that can communicate with the iSeries platform.