The AS/400 Toolbox for Java provides an easy entry into the Java environment. It allows a Java program to access AS/400 data, commands, or programs, and it handles all the work needed to sign on to an AS/400, even managing the connection. Getting started with the AS/400 Toolbox for Java is easy. The product is available as part of the AS/400 offering and the VisualAge for Java offering. You can also get it from the AS/400 Toolbox for Java home page. Once you have the product, you need to determine the Java environment you want to use (applications, applets, or servlets) and then set up your AS/400 and workstation. This article provides information to help you determine the right Java environment for you as well as the installation instructions you need to get set up and started.
IBMs AS/400 Toolbox for Java is a set of Java classes that allow a Java program to access AS/400 data, commands, or programs. The support provided by these classes is similar to the type of functions provided in the IBMs Client Access/400 APIs. However, the AS/400 Toolbox for Java does not require Client Access support in order to work. It only requires a Java Virtual Machine (JVM) at runtime and the Java Developer Kit (JDK) at development time.
The AS/400 Toolbox for Java consists of over 300 classes. These classes (which are delivered as a Java package in a compressed file) do all the work that allows a Java application to access and sign on to an AS/400, including managing the connection. The product also includes support for making a command call, making a program call, or accessing the AS/400 database using Java Database Connectivity (JDBC) or record-level access, just to name a few. The classes use the existing AS/400 servers as entry points into the system. Each server runs in a separate job on the AS/400 and sends and receives data streams on a socket connection.
The AS/400 Toolbox for Java provides an easy entry into the Java environment because it uses applications and data that already exist on the AS/400. It allows you to move data between the AS/400 and a Java program running on the AS/400, a Java program
running on a workstation, a Java applet running in a Java-enabled browser, or a Java servlet running on a Java-enabled server such as the AS/400 (available as of V4R3). It is also certified 100% Pure Java, which ensures that all of its classes will run on any JVM.
What Do I Need and Where Do I Find It?
The AS/400 Toolbox for Java is available as part of the AS/400 offering, as part of the Visual Age for Java product offering, or through the AS/400 Toolbox for Java home page.
A table listing the AS/400 and VisualAge for Java releases and the level of AS/400 Toolbox for Java available is shown in Figure 1.
The AS/400 Toolbox for Java home page is located at www.as400.ibm.com/toolbox. From the home page, you can download a trial version, participate in the current beta offering, obtain the latest programmer guide, browse through the latest AS/400 COMMON labs, or use the interactive demo.
Using .jar and .zip Files
The AS/400 Toolbox for Java product contains both a .zip and a .jar file (jt400.zip and jt400.jar). .jar files provide a way to group class files and resources needed by beans or applets. It has the same format as a .zip file, including the ability to compress the files. However, a .jar file may contain the file types .class (compiled Java byte code), .ser (serialized beans), .gif (images), or any other type of file that could be used by the bean. Simply put, a .jar file contains all the files a JavaBean requires.
The AS/400 Toolbox for Java .zip and .jar files contain the same files. Unless the environment you are using does not support .jar files (such as Java 1.0), it is recommended that you try using the .jar file.
As the number of functions provided by the AS/400 Toolbox for Java increases, so do the sizes of the .zip and .jar files. In order to reduce that size, the AS/400 Toolbox for Java now provides a JarMaker function. Even though it is called JarMaker, it works on both .zip and .jar files.
JarMaker provides the ability to create a smaller .jar or .zip file from a larger one. In addition, JarMaker can unzip a .zip or .jar file and provide user access to the individual files. It is currently available from AS/400 Toolbox for Java home page previously listed.
JarMaker can be invoked from within a Java program or used as a standalone program. It is a client-based tool that can be used wherever the JVM and Jarmaker are located. To split jt400.jar into a set of 300K files, enter the following command:
java utilities.AS400ToolboxJarMaker -split 300
To create a .jar file containing only the Toolbox classes needed to use the command call and program call functions, enter this command:
java utilities.AS400ToolboxJarMaker -component CommandCall, ProgramCall
Setting Up and Installing the AS/400 Toolbox for Java
Depending on the version of AS/400 Toolbox for Java you are using, different OS/400 releases, JDKs, and Java Swing levels are supported (see Figure 2). Note that Java Swing refers to a package of Java classes that were developed by Sun to provide advanced GUI components. The Swing classes can be downloaded for free at java.sun.com/products/ jfc/index.html.
Prior to installing the AS/400 Toolbox for Java, you need to determine where you want to install it, what you need to install on your workstation, and what you need to install on your AS/400. You may want to install the AS/400 Toolbox for Java on your workstation, on your AS/400, or both. That decision should be based on whether you are using applications, applets, or servlets.
As stated earlier, the AS/400 Toolbox for Java classes allow users to access the AS/400 using applications, applets, or servlets. Depending on your specific needs, you may use any or all of these items.
Applications
An application is a Java program that can run standalone or outside of a Web browser. It can be run from any workstation or server that has a JVM. Applications are used for non-Web environments. If you are using applications, the AS/400 Toolbox for Java can be installed on the workstation or the AS/400 server. It depends on where the application is going to be run, administration costs, and performance issues. If you have several workstations and each of them has its own copy, then there is an administration cost every time updates need to be made. However, by having the class library on the workstation, there are no performance penalties due to traffic on the communications line. The advantage of having the product on the server is that there is only one copy to update, but there is a performance cost to pay due to traffic on the communications line. However, the performance cost for this scenario is considered minor.
Applets
An applet is a Java program that runs on a Java-enabled Web browser. In other words, it works from the Web pages. Just like applications, the class files can be kept on the workstation or the server. The same considerations that apply to application class file location apply when determining where the class files for applets should be installed. However, when using applets, the performance penalty may be more significant due to the browser. The performance impact will also depend on the number of classes that need to be downloaded and the number of connections that need to be made during that time.
Servlets
A servlet is a Java program that runs on a server and returns HTML to the Web browser. Servlets are invoked by an HTML server. They should be used if you want the processing to occur on the server and the information sent back to the browser. The advantage of using a servlet is that the program runs on the server: The only data that goes over the communication lines is the HTML, thus eliminating the performance impact issue. When using servlets, the class files must be installed on the server.
Workstation Requirements
To use the AS/400 Toolbox for Java classes from workstation-based Java applications, your machine must have several other pieces of software installed. First, it will need a JVM that is at the appropriate level based on the version of AS/400 Toolbox for Java being used (see Figure 2). Second (if you are planning to use the GUI classes), it will need Suns Swing package installed. And third, that workstation will have to have TCP/IP installed and configured.
To use the AS/400 Toolbox for Java classes from within Java applets, each workstation will require a browser that supports the appropriate level of JDK. Again, if you are planning to use the GUI classes, for best results, that browser should also support Suns Swing classes, and these classes should be installed on the client system. The Swing classes can be dynamically downloaded to the browser but only at a severe performance cost.
OS/400 Requirements
To use the AS/400 Toolbox for Java classes from within host-based AS/400 applications, your AS/400 must have several software products installed:
The level of OS/400 required, based on the version of the AS/400 Toolbox for Java being used
The Host Servers option of OS/400
The TCP/IP Connectivity Utilities for AS/400 licensed program, 5769-TC1 With the appropriate software products installed, there are a few extra steps that must be done as well. The QUSER profile must be enabled and have a valid password. You can use the Work User Profile (WRKUSRPRF) command to check this:
WRKUSRPRF USRPRF(QUSER)
Also, the host servers must be started. The Start Host Servers (STRHOSTSVR) command specifying an option of ALL handles this requirement:
STRHOSTSVR *ALL
Finally, if you have OS/400 Version 4, Release 2 or later and plan to use record- level database access, you also need to start the distributed data management (DDM) server. The Start TCP Server (STRTCPSVR) command with the specification of DDM is used to enable record-level access:
STRTCPSVR *DDM
Installing the AS/400 Toolbox for Java on the AS/400
To install the AS/400 Toolbox for Java licensed program on the AS/400, enter the Restore License Program (RSTLICPGM) command. The AS/400 Toolbox for Java is license program number 5763JC1.
Placing the AS/400 Toolbox for Java Class Files on Your Workstation
Copying the class files to your workstation allows you to serve the files from your workstation.
Either the jt400.zip file or the jt400.jar file can be used on your workstation and are located on the Integrated File System (IFS) of the AS/400 in directory /QIBM/ProdData/HTTP/Public/jt400/lib.
You can chose to manually copy the .zip or .jar file from the AS/400 to your workstation by using Client Access to map a network drive or by using file transfer protocol (FTP). If using FTP, be sure the file is transferred in binary mode. You may also use the AS400ToolboxInstaller class to copy the files to your workstation. The AS400ToolboxInstaller class provides a set of APIs that install and update the AS/400 Toolbox for Java classes onto the client. The AS400ToolboxInstaller class is not a standalone application; it is a class that is intended to be a part of a Java program.
Once the files are copied to the workstation, the CLASSPATH environment on the workstation needs to be updated with the location of where you put the .zip and .jar files. So, for example, on a PC that is using the Windows 95 operating system, if jt400.jar resides in C:jt400libjt400.jar, that path needs to be added to the CLASSPATH variable. The following DOS set command appends the example path to the existing CLASSPATH much like an Add Library List Entry (ADD-LIBLE) command:
SET CLASSPATH=%CLASSPATH%C:jt400libjt400.zip
Once you have installed the AS/400 Toolbox for Java product, it is recommended that you go through the COMMON labs, which are available from the AS/400 Toolbox for Java home page. These labs will walk you through how to use the most popular functions.
The AS/400 Toolbox for Java is an easy way to become part of the Java world. Whether you want to use Java applications, applets, or servlets, this product can get you on your way to using Java with your existing AS/400 programs and data.
AS/400 Release Version of AS/400 Toolbox for Java
OS/400 Version 4 Release 2 Mod 0 OS/400 Version 4 Release 3 Mod 1 Visual Age for Java Release (Enterprise Edition ONLY)
Version 1.0 Not available Version 1.0.1 Mod 0 Version 1.0.0 (AS/400 Fix Pack) Mod 0 Version 2.0 (U.S. English) Mod 1 Version 2.0 (NL Version) Mod 1
Figure 1: Releases of AS/400 Toolbox for Java
AS/400 Toolbox OS/400 Releases Supported JDK Required Java Swing Level for Java Release Required
Mod 0 V3R2, V3R7, V4R1, V4R2 JDK 1.1.2 or later None
Mod 1 V3R2, V4R1, V4R2, V4R3 JDK 1.1.5 or later 1.0.2 or later
Figure 2: The toolboxs release levels have different OS/400, JDK, and Suns Swing package support requirements
LATEST COMMENTS
MC Press Online