16
Tue, Apr
7 New Articles

The AS/400 Toolbox for Java Tutorial

Java
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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.

IBM’s 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 IBM’s 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 Sun’s 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 Sun’s 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 toolbox’s release levels have different OS/400, JDK, and Sun’s Swing package support requirements

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: