Getting Started With Java and AS400 - Java On AS400 (Java400)
Getting Started With Java and AS400 - Java On AS400 (Java400)
Java has the potential to connect users with information regardless of its source.
Whether the data comes from the web, a database, an integrated file system, or
any other entity, Java can control it. Using Java with your AS/400 opens a new
world of flexibility and manageability. You can create applications that run from
just about anywhere, and still provide access to your AS/400 resources. You can
use the web, Java, and AS/400 together with ease. This list highlights only some of
the many advantages Java and AS/400 have to offer.
Internet applications
v Use the web, Java, and AS/400 together with servlets.
v Provide secure connections to AS/400.
v Create dynamic HTML with AS/400 Toolbox for Java HTML classes.
v Create Java applets.
AS/400 applications
v Call AS/400 programs and service programs.
v Perform administrative tasks with AS/400 Toolbox for Java utility classes.
v Create client/server database applications with the AS/400 Toolbox for Java
JDBC drivers.
v Create native AS/400 database applications with the AS/400 Developer Kit for
Java JDBC drivers.
v Access legacy AS/400 data and applications.
v Create optimized Java code for specific AS/400 operations using the AS/400
Developer Kit for Java.
v Create client/server Java applications with the AS/400 Toolbox for Java.
v Easily create graphical user interfaces (GUIs) with the Graphical Toolbox, a
visual editing tool. (Uses the AS/400 Toolbox for Java)
Java in general
v Create graphical user interfaces (GUIs) to present and request data from users.
v Enjoy the benefits of Object-Oriented programming with Java. (i.e. code reuse,
inheritance, abstraction)
v Use Java with other languages, such as C++ and RPG.
v Enjoy Java’s inherent features such as, garbage collection, security, and platform
independence.
Make sure to see the AS/400 Developer Kit for Java documentation for all the
resources, tips, and information you need while creating your Java applications.
Keep up-to-date with the latest technologies and innovations; see Other
Information about Java and AS/400 for links and other resources.
For more information about AS/400 Developer Kit for Java, see the AS/400
Developer Kit for Java product information.
If you want to know how standard Java commands and AS/400 commands can
possibly work together, the answer is Qshell Interpreter. Qshell Interpreter
provides a UNIX-like command environment, or shell (in fact, Qshell closely
resembles the UNIX Korn shell). Install Qshell Interpreter, and you can run the
For more information about Qshell Interpreter, see the Qshell Interpreter product
documentation.
During your deployment cycle to the AS/400 system, it is a good idea to keep an
eye on which PTFs are needed to run your product successfully. Your customers
will also need to know this information. Therefore, it is highly recommended that
you have the latest PTFs installed and applied on your AS/400 system.
Make sure you visit the following links for the most current information:
v AS/400 Toolbox for Java PTFs
v WebSphere Application Server PTFs
Also, it is recommended that you request every 2 months or so the latest Group
PTF for the following licensed products:
V4R5 works with the Java 2 Software Development Kit which includes the JDK 1.2
and Swing 1.1 classes.
New examples
Two code examples were added to show how Java can interact with the AS/400
database.
A new section titled What can you do with Java and AS/400? was added.
The small links at the top of each page show you where you are in our
information. These links are displayed in a directory structure format. To see where
you are, read through the links. For example, if you look at the top of this page,
you see:
Getting started with Java and AS/400 \ What’s new for V4R5
These links show that you are in the ″What’s new for V4R5″ information under the
″Getting Started with Java and AS/400″ topic.
To help you see where technical changes have been made, this information uses:
Note: To find out if a licensed program has been installed, press F11 on the Install Licensed
Programs display. An installed licensed program displays *COMPATIBLE in the Installed
Status field.
If QShell Interpreter does not appear on the Install Licensed Programs menu at all, you need
to use the restore licensed programs (RSTLICPGM) method to install the licensed programs
from CD-ROM, disk, or tape.
4. Next, look for 5769JV1. Notice that 5769JV1 has five entries, a base component
(AS/400 Developer Kit for Java) and four options (Java Developer Kit 1.1.6
through Java Developer Kit 1.2) as shown below:
5769JV1 *BASE AS/400 Developer Kit for Java
5769JV1 1 Java Developer Kit 1.1.6
5769JV1 2 Java Developer Kit 1.1.7
5769JV1 3 Java Developer Kit 1.2
5769JV1 4 Java Developer Kit 1.1.8
The AS/400 Developer Kit for Java provides support for multiple JDK’s. You
can install a combination of options and program with any. If your Java
program does not specify which JDK version to use, a default JDK is selected.
For more information about multiple JDK versions and AS/400 Developer Kit
for Java, see AS/400 Developer Kit for Java product documentation.
Note:You may have to scroll through several pages to find both entries. If one (or both) of
these choices does not appear on the Install Licensed Programs menu, you need to use the
restore licensed programs (RSTLICPGM) method to install the licensed programs from
CD-ROM, disk, or tape.
Note: If you are installing from a tape drive, the device ID is usually in the format TAPXX,
where XX is a number, like 01.
5. Keep the default settings for the other parameters in the Restore Licensed
Program display. Press the Enter key.
6. More parameters appear. Keep these default settings also. Press the Enter key.
The program will begin installing.
When the licensed program is finished installing, the Restore Licensed Programs
display appears again.
Note: If you do not a network drive set up on your workstation, you can use AS/400
Client Access to map a network drive to your AS/400.
Note: If you cannot map a network drive to your AS/400, you can write a Java application
on your AS/400 system.
Workshop.
You must have a connection configured for the AS/400 system before you can map
a network drive.
1. Open Windows Explorer:
a. Right-click on the Start button on your Windows taskbar.
b. Click Explore in the pop-up menu.
2. Select Map Network Drive from the Tools pulldown menu.
If you do not have an IDE or other programming software, you can always code
your Java application into a any text-based editor (like Windows Notepad).
However you code your application, save it in the directory you created on your
AS/400, which you access through the drive you have mapped to your AS/400
system. Make sure you follow the Java naming convention when you choose the
name of your application.
For example, the Java application listed below creates the class
CommandCallExample.
If you look at the example title bar, you will notice it’s named
CommandCallExample.java.
CRTLIB LIB(mylib)
Note: When choosing a name for the source physical file, you do not have to follow Java
file naming conventions (for example, naming your Java application after the class that is
instantiated). The file you are creating here acts only as a receptacle for your Java source
code. You can create another file for the source code later.
A message appears at the bottom of your screen, stating “File MYFILE created
in library MYLIB.”
3. Create the source code for the file, using PDM.
4. Copy the source code to a stream file in your directory. Java applications on
AS/400 must reside in a directory in the integrated file system. If you copy
your source code to a stream file, you can save it in your directory.
where myfile is the name of your Java program, mylib is the name of the library
in which you saved it, and myclass is the name of the file member you are
creating.
Note: You may want to replace myclass with an abbreviated form of your Java class name.
where myclass is the name of your Java program, where myfile is the name of
your physical source file, and where mylib is the name of the library in which
you saved your file.
Note: Entering 819 in the Stream file code page field saves the file as ASCII.
where mylib is the name of the library you created, myfile is the name of your file,
and myclass is the name of the source member you created for your source code.
Replace mydir with the name of the directory in which you want to save your Java
program, and replace myjavaclass with the class name of your Java application.
Note: See Name your Java application for more information on the Java file naming
convention.
A message appears at the bottom of your screen, stating “Database file member
copied to object.”
Stream file
An AS/400 stream file is a file that contains a continuous stream of data, similar to
UNIX and Windows files. The source physical file you created is a structured
AS/400 database file. To compile your AS/400 Java application, it must be in a
format the Java compiler recognizes, which is a stream file.
CRTJVAPGM creates a hidden service program, associated with your class file, that
improves performance. CRTJVAPGM also has an OPTIMIZE parameter that allows
you to select the level of optimization for your service program.
Note: It’s advised that you run the CRTJVAPGM command on all Java classes, JAR files,
and ZIP files you create.
Note: See AS/400 Developer Kit for Java documentation for more information about the
parameters on the CRTJVAPGM command.
AS/400 Developer Kit for Java features Remote AWT capabilities. With Remote
AWT configured on your AS/400 and a client workstation, the AWT graphics of
your AS/400 Java application (running on your AS/400) can be displayed remotely
on your client workstation.
To set up Remote AWT, visit the AS/400 Developer Kit for Java documentation on
setting up Remote AWT.
v AS/400 Toolbox for Java home page . Visit this site for information about
using AS/400 Toolbox for Java, troubleshooting, code updates, and downloads.
Servlets perform many of the same functions that CGI (common gateway interface)
programs do. However, because servlets can be pre-loaded by the web server,
servlets are usually faster than CGI programs that perform the same functions.
Servlets are also easier to write and maintain than CGIs, and they are reusable
across other server platforms.
v JavaSoft Servlets . This site is Sun Microsystem’s home for Java Servlets.
Check out the Servlet API (applied programming interface) and links to other
non-platform specific servlets resources.
Note: See the Java education page for information about learning the Java programming
language.
Books
v Java for RPG Programmers by Phil Coulthard and George Farr of IBM
Toronto. Currently the only available AS/400-specific guide to Java, this book is
extremely helpful for Java programming on AS/400. Also includes a MINQ Java
tutorial CD-ROM, Introduction to Java Programming using VisualAge for Java
Enterprise.
Product documentation (manuals)
v AS/400 Developer Kit for Java
ITSO Redbooks
Note: You will need Adobe Acrobat Reader to view this document.
Note: You will need Adobe Acrobat Reader to view this document.
Magazines
v NEWS/400 magazine offers several good AS/400 and Java resources in its
Java Community such as The Java Tutorial, Java articles archive, and a Java
newsletter called Java Enterprise Solutions.
v AS/400 and Java home page features white papers on AS/400 and Java,
providing links to other Java resources.
v AS/400 Toolbox for Java home page. View all sorts of information about
AS/400 Toolbox for Java, including evaluation downloads, troubleshooting, and
frequently-asked questions.
v IBM Centre for Java Technology Development. Visit this site from IBM
Hursley for Java news, information, free code downloads, and environment
support for all IBM platforms.
v IBM Java home page. Subtitled “The Ultimate Resources for Java
Developers,” IBM’s main Java site offers developer tools and assistance,
technology previews, Java tutorials and education, feature articles, and JCentral,
a search engine tuned to Java on the Internet.
v VisualAge for Java and AS/400 home page. If you are interested in what an
integrated development environment (IDE) like VisualAge for Java can do for
your Java and AS/400 programming, see this site.
Newsgroups, forums, and mailing lists
Newsgroups
v AS/400 newsgroup
Forums
Mailing lists
Java education
Learning Java does not have to be expensive. You can find several good Java
tutorials on the Internet as well as other materials like books and articles.
Listed below are some good resources for learning about Java programming. See
both 22 and 23 links.
v This course is part of the IBM Education and Training AS/400 Curriculum.
v Java for RPG Programmers by Phil Coulthard and George Farr of IBM
Toronto. Currently the only available AS/400-specific guide to Java, this book is
extremely helpful for learning Java programming for AS/400. The book also
includes a MINQ Java tutorial CD-ROM, Introduction to Java Programming using
VisualAge for Java Enterprise.
General Java education
v The Java Tutorial lists online Java tutorials (basic and advanced Java topics)
available from Sun Microsystems, Inc.
v JavaÖ Programming Language Basics, Part 1 walks through how to use the
Java« 2 Platform software to create and run three common types of programs
written for the Java platformùapplications, applets, and servlets. (Sun
Microsystems, Inc.)
Printed in U.S.A.