Java 400
Java 400
IBM
Getting Started with Java and AS/400: Java
on AS/400
Copyright International Business Machines Corporation 1997, 1998. All rights reserved.
Note to U.S. Government Users Documentation related to restricted rights Use, duplication or disclosure is
subject to restrictions set forth in GSA ADP Schedule Contract with IBM Corp.
Contents
Chapter 1. Set up Java on AS/400 . . . . . . . . . . . . . . . . .
AS/400 Developer Kit for Java . . . . . . . . . . . . . . . . . . .
Qshell Interpreter. . . . . . . . . . . . . . . . . . . . . . . .
1
1
1
3
4
.
.
.
.
.
.
.
or
.
. .
. .
. .
. .
. .
. .
. .
98) .
. .
5
5
6
6
8
10
10
17
21
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
23
23
25
26
26
26
27
28
29
30
31
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
33
33
36
36
37
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
iii
iv
Qshell Interpreter
You might have written some Java programs on other platforms, like Windows or
UNIX. If so, you know the standard Java commands such as java, javac, jdb, and
rmic. And, if you have spent any time on an AS/400, you know that AS/400
commands are unique in the computing world.
If you are starting to wonder 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
standard Java commands and AS/400 commands from the same environment.
Qshell Interpreter is not a pre-requisite for running Java on AS/400, but it sure
helps.
Note: For more information about Qshell Interpreter, see the Qshell Interpreter product
documentation.
4. Next, look for 5769JV1. Notice that 5769JV1 has three entries, a base
component (AS/400 Developer Kit for Java) and two options (Java Developer
Kit 1.1.6 and Java Developer Kit 1.1.7) as shown below:
5769JV1
5769JV1
5769JV1
*BASE
1
2
For V4R4, AS/400 Developer Kit for Java provides support for both Java
Development Kit (JDK) 1.1.6 and 1.1.7. You can install both options and
program with either. If your Java program does not specify which JDK version to
use, JDK 1.1.7 is the default. 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 will probably 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 will
need to use the restore licensed programs (RSTLICPGM) method to install the licensed
programs from CD-ROM, disk, or tape.
5. We suggest that you keep the default settings for the other parameters in the
Restore Licensed Program display. Press the Enter key.
6. More parameters appear. We suggest that you 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.
[ Legal | AS/400 Glossary ]
If you do not plan to use AWT graphics in your Java applications, you do not need
to set up Remote AWT.
For this setup, we assume that you have:
v A Win32 workstation (Windows 95, 98, or NT)
v TCP/IP installed and configured on your AS/400 and workstation.
Note:For more information about TCP/IP, see the TCP/IP Fastpath
Setup(http://publib.boulder.ibm.com:80/cgi-bin/bookmgr/BOOKS/QB3A0K00/CCONTENTS
and OS/400 TCP/IP Configuration and Reference(http://publib.boulder.ibm.com:80/cgibin/bookmgr/BOOKS/QB3ANL02/CCONTENTS
manuals.
2. After you have finished downloading the JDK, follow the To continue
instructions located below the purple download box to install the JDK.
3. Download the JDK documentation from
Make sure you select ZIP
http://java.sun.com:80/products/jdk/1.1/doc.html
file for Windows in the Select Download Format pull-down window.
You need a ZIP file extraction program to install the JDK documentation files. For more
information about ZIP extraction programs, see the JDK documentation installation
instructions (http://java.sun.com:80/products/jdk/1.1/install-docs.html#unbundle).
4. After you have downloaded the JDK documentation ZIP file, follow the To
continue instructions located below the purple download box to install the
documentation.
[ Legal | AS/400 Glossary ]
3. Select the drive (for example, X:) you want to connect to your AS/400.
4. Type the path name to the your AS/400 system. For example:
\\MYAS400
where MYAS400 is the name of your AS/400 system.
A message will appear, similar to '230 USER logged on,' where USER is your
AS/400 User ID.
6. Specify binary transfer mode. At the DOS prompt, type:
bin
and press the Enter key.
A message will appear, stating '200 Representation type is binary IMAGE.'
7. Navigate to the jt400 directory on your AS/400. Type:
cd /QIBM/ProdData/Java400/jdkxxx
where xxx is your installed version of AS/400 Developer Kit for Java.
Press the Enter key.
A message will appear, stating '250 '/QIBM/ProdData/Java400/jdkxxx' is
current directory.'
8. Get the RAWTGui.zip file. Type:
mget RAWTGui.zip
and press the Enter key.
A prompt, 'mget RAWTGui.zip?' will appear. Type y and press the Enter key.
Two messages will appear, stating '200 PORT subcommand request
successful' and '150 Retrieving file
/QIBM/ProdData/Java400/jdkxxx/RAWTGui.zip.'
After a few moments, two more messages appear, '250 File transfer
completed successfully' and a message similar to '1238147 bytes received
in 1.65 Seconds (750.39Kbytes/sec).' These messages signal the successful
completion of FTP.
9. End the FTP session. Type:
quit
and press the Enter key.
10. End the MS-DOS session. Type exit and press the Enter key.
[ Legal | AS/400 Glossary ]
10
Update your PATH and CLASSPATH statements for JDK (Win NT)
Add references to the JDK to your PATH and CLASSPATH statements, located in
the Environment panel of your System Properites window:
11
1. In the System Variables window, find the variable Path and click on it. Notice
that the variable and its value appear in the two text fields at the bottom of the
display.
12
Click the Set button. The Variable and Value text fields clear, and the new
value is added to the system variables.
3. In the System Variables window, look for the ClassPath variable.
If you find the ClassPath variable, click it. At the end of the text in the Value
field, add:
;.;X:\JDK1.1.Y\LIB\classes.zip
where X is the drive on which JDK is installed, and Y is the version number of
JDK 1.1 you installed.
Note: The period (.) in the CLASSPATH statement specifies the current directory. With this
setting, you do not have to specify the full path name (which includes drive and directory
structure) of your Java application to compile or run it.
This action sets your workstations CLASSPATH variable to the JDK class
library, classes.zip. When you compile or run a Java application, the system will
automatically locate classes.zip.
Chapter 3. Set up Remote AWT
13
You do not have to click the Set button just yet; we will be adding more to the
CLASSPATH value.
14
15
3. Click the Set button. The Variable and the Value fields clear, and the new
values appear in the System Variables window.
[ Legal | AS/400 Glossary ]
16
3. Click the Set button. The Variable and the Value fields clear, and the new
values appear in the System Variables window.
[ Legal | AS/400 Glossary ]
17
Open AUTOEXEC.BAT
Your workstations AUTOEXEC.BAT file contains the programming environment
variables. When you start your workstation, the AUTOEXEC.BAT file sets your
workstations environment.
Follow these steps to open your workstations AUTOEXEC.BAT file.
1. Click on the Start button in the lower left corner of your desktop.
2. Position your mouse over Find.... Select Files or Folders from the Find menu.
3. In the Named field, type autoexec.bat. In the Look in field, select the drive on
which Windows 95 is located. Click on the Find Now button.
4. In the bottom window, right-click on Autoexec.bat.
Note: More that one Autoexec.bat file may be found. More than likely, the first instance is the
one you want. Ignore any occurrance that is located in the backup directory structure.
5. Select Edit from the pop-up menu. If you are prompted to choose a program,
pick Notepad.
[ Legal | AS/400 Glossary ]
18
This action sets your workstations CLASSPATH variable to the JDK class
library, classes.zip. When you compile or run a Java application, the system will
automatically locate classes.zip.
The example below shows, in brown, how we modified our AUTOEXEC.BAT file to
include the JDK in our environment variables. The black text shows how our
AUTOEXEC.BAT file originally read. We installed the JDK 1.1.7 on our C: drive.
Your workstations setup may differ, depending on your version of JDK and the drive
on which it is installed.
19
20
21
22
23
3. Select the drive (for example, X:) you want to connect to your AS/400.
4. Type the path name to the your AS/400 system. For example:
\\MYAS400
where MYAS400 is the name of your AS/400 system.
24
25
If you look at the title bar in our example, you will notice that we have named our
application CommandCallExample.java.
[ Legal | AS/400 Glossary ]
26
Note: On AS/400, libraries are not equivalent to directories. The system will not allow you to
save a source physical file in a directory. You must save the file in a library.
myfile
mylib
where myfile is the name of the file you created, and mylib is the name of the
library in which you saved the file.
27
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. > myfile
. > mylib
. myclass
.
TXT
where myfile is the name of your Java program, where 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: We suggest you replace myclass with an abbreviated form of your Java class name.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Y
myclass
myfile
mylib
N
N
N
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.
Press the Enter key.
The Work with Members Using PDM screen appears.
8. Exit PDM by pressing the F3 key twice.
[ Legal | AS/400 Glossary ]
28
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.
29
30
31
32
updates to the AS/400 Developer Kit for Java product, so check it often to keep
your software up-to-date.
v Building AS/400 Applications with Java, Version 2
http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/SG242163
(ITSO
Redbook) features projects and code examples using AS/400 Developer Kit for
Java.
v Java for RPG Programmers (http://www.advice.com/ibm/JavaRPG/javarpg.html).
Currently, this is the only AS/400-specific introduction to Java. Even if you
do not know RPG, you will still find the book invaluable for its description of Java
in AS/400 terms.
Be sure to check out our collection of Java and AS/400 resources. We will point you
to books, manuals, websites, magazines, and newsgroups that focus on Java on
AS/400.
[ Legal | AS/400 Glossary ]
Books
v Java for RPG Programmers (http://www.advice.com/ibm/JavaRPG/javarpg.html)
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.
33
has
examples of migrating RPG applications to Java. We know you will find it very
useful.
v Building AS/400 Client/Server Applications with Java
(http://publib.boulder.ibm.com/pubs/pdfs/redbooks/sg242152.pdf)
features
projects and code examples using AS/400 Toolbox for Java.
Note:You will need Adobe Acrobat Reader
(http://www.adobe.com/prodindex/acrobat/readstep.html)
shows how
Magazines
v NEWS/400 magazine (http://www.news400.com)
Since
MC does not publish many of their articles on the Internet, you will probably want
to get a subscription for the good Java articles they frequently feature. You can
also browse through and order back issues for any good articles you might have
missed. MC also publishes the AS/400 NetJava Expert
(http://midrangecomputing.com/ie/)
newsletter.
v Midrange Systems magazine (http://www.midrangesystems.com).
Not only
can you receive a free subscription to Midrange Systems, you can view the
magazine online. Search the archive for Java articles.
Internet sites
v AS/400 and Java home page (http://iws.as400.ibm.com/java/javaframe.htm)
features white papers on AS/400 and Java, providing links to other Java
resources.
34
Developer Kit for Java licensed program, this site offers valuable information
about updates for the product.
v AS/400 Toolbox for Java home page
View all sorts of
(http://iws.as400.ibm.com/toolbox/welcome.htm).
information about AS/400 Toolbox for Java, including evaluation downloads,
troubleshooting, and frequently-asked questions.
v Qshell Interpreter home page (http://www.as400.ibm.com/developer/qshell/)
provides references, downloads, and frequently-asked questions about the
Qshell Interpreter licensed program.
v AS/400 Partners in Development Java page
(http://www.as400.ibm.com/developer/java/).
dedicated to Java and AS/400, this home page features articles, demonstrations,
solutions, resources, and information about 'real world' Java implementations by
AS/400 business partners.
v IBM Centre for Java Technology Development
(http://ncc.hursley.ibm.com/javainfo/hurindex.html).
Hursley for Java news, information, free code downloads, and environment
support for all IBM platforms.
Subtitled 'The Ultimate
v IBM Java home page (http://www.ibm.com/java/).
Resources for Java Developers,' IBMs 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 IBM SanFrancisco home page (http://www.ibm.com/Java/Sanfrancisco/).
IBM SanFrancisco is a Java-based collection of business application components
that allows you to assemble server-side applications from pre-existing parts. The
SanFrancisco home page provides information and resources about the project.
v VisualAge for Java and AS/400 home page
(http://www.software.ibm.com/ad/as400/vajava/).
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 IBM Hursley AS/400 Java Environment newsgroup
(news:ncc.hursley.ibm.com/ibmpub.java.os400)
v AS/400 newsgroup (news:comp.sys.ibm.as400.misc)
Forums
v IBM Hursley AS/400 Java Environment forum
(http://ncc.hursley.ibm.com/newsgroups/ncc/nccnews?ibmpub.java.os400)
v Midrange Computing Java Programming Discussion forum
(http://www.midrangecomputing.com/forums/)
35
Mailing lists
v MIDRANGE dot COM JAVA/400 mailing list (http://www.midrange.com/java400l.htm)
[ Legal | AS/400 Glossary ]
Java education
Unlike acquiring other new skills, learning Java does not have to be expensive. You
can find several good Java tutorials on the Internet as well as other educational
materials like books and articles.
Listed below are some of our favorite resources for learning about Java
programming. We have included both 36 and a few 36 links.
See our Java and AS/400 resources for other links that will be helpful in your Java
education.
features
36
includes online
courses, classroom training, white papers, tutorials, articles, books, and FAQs.
lists
v The Java Tutorial (http://java.sun.com/docs/books/tutorial/index.html)
online Java tutorials (basic and advanced Java topics) available from Sun
Microsystems.
[ Legal | AS/400 Glossary ]
37
IBMR
Printed in U.S.A.