32
Getting Started with Java and AS/400: Java on AS/400

Getting Started With Java and AS400- Java on AS400(Java400)

Embed Size (px)

Citation preview

Page 1: Getting Started With Java and AS400- Java on AS400(Java400)

Getting Started with Java and AS/400: Javaon AS/400

���

Page 2: Getting Started With Java and AS400- Java on AS400(Java400)
Page 3: Getting Started With Java and AS400- Java on AS400(Java400)

Getting Started with Java and AS/400: Javaon AS/400

���

Page 4: Getting Started With Java and AS400- Java on AS400(Java400)

© Copyright International Business Machines Corporation 1998, 1999. All rights reserved.US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contractwith IBM Corp.

Page 5: Getting Started With Java and AS400- Java on AS400(Java400)

Contents

Chapter 1. What can you do with Javaand AS/400? . . . . . . . . . . . . . 1

Chapter 2. Setting up Java on AS/400 . . 3AS/400 Developer Kit for Java overview . . . . . 3Qshell Interpreter and Java . . . . . . . . . 3PTFs for Java and AS/400 . . . . . . . . . . 4What’s new for V4R5 . . . . . . . . . . . 4

Chapter 3. Installing the licensedprograms for Java on AS/400 . . . . . 7Installing a licensed program with the RestoreLicensed Program command for Java on AS/400 . . 8

Chapter 4. Creating a Java applicationfor your AS/400 . . . . . . . . . . . 9Mapping a network drive to AS/400 . . . . . . 9

Creating a directory on your AS/400 . . . . . 11

Writing a Java application on your workstation . . 12Naming your Java application . . . . . . . 12

Writing your Java program on AS/400 . . . . . 12Creating the Java source code . . . . . . . 13Copying your Java code to a stream file . . . . 15Stream file . . . . . . . . . . . . . . 15

Compiling your Java application from QshellInterpreter . . . . . . . . . . . . . . . 16Optimizing your Java application . . . . . . . 16Running your Java application from QshellInterpreter . . . . . . . . . . . . . . . 17Creating graphical applications with Java on AS/400 17

Chapter 5. Other information aboutJava and AS/400 . . . . . . . . . . 19Getting Started with Java and AS/400: Servlets . . 19

More servlet resources . . . . . . . . . . 20Java and AS/400 resources . . . . . . . . . 20Java education . . . . . . . . . . . . . 22

© Copyright IBM Corp. 1998, 1999 iii

Page 6: Getting Started With Java and AS400- Java on AS400(Java400)

iv Getting Started with Java and AS/400: Java on AS/400

Page 7: Getting Started With Java and AS400- Java on AS400(Java400)

Chapter 1. What can you do with Java and AS/400?

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, orany other entity, Java can control it. Using Java with your AS/400 opens a newworld of flexibility and manageability. You can create applications that run fromjust about anywhere, and still provide access to your AS/400 resources. You canuse the web, Java, and AS/400 together with ease. This list highlights only some ofthe 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.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

© Copyright IBM Corp. 1998, 1999 1

Page 8: Getting Started With Java and AS400- Java on AS400(Java400)

2 Getting Started with Java and AS/400: Java on AS/400

Page 9: Getting Started With Java and AS400- Java on AS400(Java400)

Chapter 2. Setting up Java on AS/400

It’s easy to set up Java programming on your AS/400 system. To create your firstJava application on AS/400 complete the following steps:1. Installing licensed programs for Java.

a. AS/400 Developer Kit for Java (5769-JV1)b. Qshell Interpreter (5769-SS1)

2. Creating a Java application.a. Creating a directory for your Java application.b. Writing a Java application.c. Compiling your Java application.d. Optimizing your Java application.e. Running your Java application.

Continuing with Java on AS/400

Make sure to see the AS/400 Developer Kit for Java documentation for all theresources, tips, and information you need while creating your Java applications.Keep up-to-date with the latest technologies and innovations; see OtherInformation about Java and AS/400 for links and other resources.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

AS/400 Developer Kit for Java overviewThe AS/400 Developer Kit for Java is optimized for use in an AS/400 serverenvironment; it allows you to create and run Java programs on AS/400. TheAS/400 Developer Kit for Java is a compatible implementation of the SunMicrosystems, Inc. Java Technology, and functions much like their JavaDevelopment Kit (JDK). It provides AS/400-specific core classes, utilities, tools, anda Java runtime environment.

For more information about AS/400 Developer Kit for Java, see the AS/400Developer Kit for Java product information.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Qshell Interpreter and JavaYou might have written some Java programs on other platforms, like Windows orUNIX. If so, you know the standard Java commands such as java, javac, jdb, andrmic. And, if you have spent any time on an AS/400, you know that AS/400commands are unique in the computing world.

If you want to know how standard Java commands and AS/400 commands canpossibly work together, the answer is Qshell Interpreter. Qshell Interpreterprovides a UNIX-like command environment, or shell (in fact, Qshell closelyresembles the UNIX Korn shell). Install Qshell Interpreter, and you can run the

© Copyright IBM Corp. 1998, 1999 3

Page 10: Getting Started With Java and AS400- Java on AS400(Java400)

standard Java commands and AS/400 commands from the same environment.Qshell Interpreter is not needed for running Java on AS/400, but it sure helps.

For more information about Qshell Interpreter, see the Qshell Interpreter productdocumentation.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

PTFs for Java and AS/400For those of you new to the AS/400 platform, a PTF, or program temporary fix is atemporary solution to or bypass of a problem diagnosed by IBM as resulting froma defect in a current unaltered release of a licensed program. PTFs are designed toreplace one or more objects in the product. Generally, PTFs are incorporated in afuture release of the product.

During your deployment cycle to the AS/400 system, it is a good idea to keep aneye on which PTFs are needed to run your product successfully. Your customerswill also need to know this information. Therefore, it is highly recommended thatyou 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 GroupPTF for the following licensed products:

OS/400 release Product(s) Group PTFV4R2 5769-999 (SLIC)

5769-SS1 (XPF)5769-JV1 (Java)

SF99065

V4R3 5769-999 (SLIC)5769-SS1 (XPF)5769-JV1 (Java)

SF99066

V4R4 5769-999 (SLIC)5769-SS1 (XPF)5769-JV1 (Java)

SF99067

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

What’s new for V4R5Install Java 2 Software Development Kit (J2SDK)

V4R5 works with the Java 2 Software Development Kit which includes the JDK 1.2and Swing 1.1 classes.

New examples

Two code examples were added to show how Java can interact with the AS/400database.

4 Getting Started with Java and AS/400: Java on AS/400

Page 11: Getting Started With Java and AS400- Java on AS400(Java400)

What can you do with Java and AS/400?

A new section titled What can you do with Java and AS/400? was added.

How to see your current position in our information:

The small links at the top of each page show you where you are in ourinformation. These links are displayed in a directory structure format. To see whereyou 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.

How to see what’s new or changed:

To help you see where technical changes have been made, this information uses:

v The image to mark where new or changed information begins.

v The image to mark where new or changed information ends.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Chapter 2. Setting up Java on AS/400 5

Page 12: Getting Started With Java and AS400- Java on AS400(Java400)

6 Getting Started with Java and AS/400: Java on AS/400

Page 13: Getting Started With Java and AS400- Java on AS400(Java400)

Chapter 3. Installing the licensed programs for Java onAS/400

To program Java on AS/400, you must install AS/400 Developer Kit for Java. Asuggested installation, the Qshell Interpreter, provides a UNIX-like shellenvironment that provides support for standard Java commands.

To install these licensed programs, follow these steps:1. At the AS/400 command prompt, type:

GO LICPGM

Press Enter.The Work with Licensed Programs display appears.

2. Select menu option 11 to install the licensed programs.3. Scroll through the list by pressing the PageDown key. Find 5769SS1 OS/400 -

QShell Interpreter, and if it has not been installed, type 1 (Install) in the Optionblank in front of it.

Note: To find out if a licensed program has been installed, press F11 on the Install LicensedPrograms display. An installed licensed program displays *COMPATIBLE in the InstalledStatus field.

If QShell Interpreter does not appear on the Install Licensed Programs menu at all, you needto use the restore licensed programs (RSTLICPGM) method to install the licensed programsfrom 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.6through Java Developer Kit 1.2) as shown below:

5769JV1 *BASE AS/400 Developer Kit for Java5769JV1 1 Java Developer Kit 1.1.65769JV1 2 Java Developer Kit 1.1.75769JV1 3 Java Developer Kit 1.25769JV1 4 Java Developer Kit 1.1.8

The AS/400 Developer Kit for Java provides support for multiple JDK’s. Youcan install a combination of options and program with any. If your Javaprogram does not specify which JDK version to use, a default JDK is selected.For more information about multiple JDK versions and AS/400 Developer Kitfor 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) ofthese choices does not appear on the Install Licensed Programs menu, you need to use therestore licensed programs (RSTLICPGM) method to install the licensed programs fromCD-ROM, disk, or tape.

5. Press Enter. The programs will begin installing.

When the licensed programs are finished installing, the Work with Licensed Programsdisplay appears again.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

© Copyright IBM Corp. 1998, 1999 7

Page 14: Getting Started With Java and AS400- Java on AS400(Java400)

Installing a licensed program with the Restore Licensed Programcommand for Java on AS/400

The programs listed in the Install Licensed Programs display are those supported bythe LICPGM installation when your system was new. Occasionally, new programsbecome available which are not listed as licensed programs on your system. If thisis the case with the program you want to install, you must use the RestoreLicensed Program (RSTLICPGM) command to install it.

To install a licensed program with the Restore Licensed Program (RSTLICPGM)command, follow these steps:1. Put the tape or CD-ROM containing the licensed program in the appropriate

drive.2. On the AS/400 command line, type:

RSTLICPGM

and press the Enter key.The Restore Licensed Program (RSTLICPGM) display appears.

3. In the Product field, type the ID number of the licensed program you want toinstall.

4. In the Device field, specify your install device.

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 LicensedProgram 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 Programsdisplay appears again.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

8 Getting Started with Java and AS/400: Java on AS/400

Page 15: Getting Started With Java and AS400- Java on AS400(Java400)

Chapter 4. Creating a Java application for your AS/400

You can create a Java application that runs on your AS/400 using any of severaldifferent methods. However, it’s easiest writing your Java applications on yourworkstation and saving them on your AS/400 through a mapped network drive.

Note: If you do not a network drive set up on your workstation, you can use AS/400Client Access to map a network drive to your AS/400.

Developing Java applications on your workstation allows you to take advantage ofone of the numerous graphical-based integrated development environment (IDE)products for Java and other programming tools that are currently on the market.

Follow these steps to create a Java application:1. Creating a directory on your AS/400 for your Java applications.2. On your workstation, write your Java application and save it on your network

drive.

Note: If you cannot map a network drive to your AS/400, you can write a Java applicationon your AS/400 system.

3. Compiling your Java application from Qshell Interpreter.4. Optimizing your Java application from Qshell Interpreter.5. Running your Java application from Qshell Interpreter.

Creating graphical applications An introduction and link to running Java graphicson AS/400. If you do not plan on using graphics, skip this section.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Mapping a network drive to AS/400For these steps, you need AS/400 Client Access for Windows installed on yourAS/400 and on your workstation. For more information on how to install andconfigure AS/400 Client Access, see the AS/400 Technical Studio Client Access

Workshop.

You must have a connection configured for the AS/400 system before you can mapa 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.

© Copyright IBM Corp. 1998, 1999 9

Page 16: Getting Started With Java and AS400- Java on AS400(Java400)

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.

10 Getting Started with Java and AS/400: Java on AS/400

Page 17: Getting Started With Java and AS400- Java on AS400(Java400)

5. If the Reconnect at logon checkbox is empty, click on it.6. Click OK to finish.

Your mapped drive will appear in the All Folders section of Windows Explorer.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Creating a directory on your AS/400You should create a directory on your AS/400 in which you can save your Javaapplications. If you have previously created a directory that you would like to useto store your Java programs, you can skip these steps.

To create a directory on your AS/400, follow these steps:1. Sign on to your AS/400.2. On the AS/400 command line, type:CRTDIR DIR(’/mydir’)where mydir is the name of the directory you are creating.Press the Enter key.A message appears at the bottom of your screen, stating “Directory created.”

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Chapter 4. Creating a Java application for your AS/400 11

Page 18: Getting Started With Java and AS400- Java on AS400(Java400)

Writing a Java application on your workstationIf you have an integrated development environment (IDE) product installed onyour workstation, use it to code your Java application. See the instructions thatcame with your software for information on creating a Java application.

If you do not have an IDE or other programming software, you can always codeyour Java application into a any text-based editor (like Windows Notepad).

However you code your application, save it in the directory you created on yourAS/400, which you access through the drive you have mapped to your AS/400system. Make sure you follow the Java naming convention when you choose thename of your application.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Naming your Java applicationWhen naming your Java application, make sure you use the proper namingconvention—name the application with the same name as the class you arecreating.

For example, the Java application listed below creates the classCommandCallExample.

If you look at the example title bar, you will notice it’s namedCommandCallExample.java.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Writing your Java program on AS/400To create a source physical file for your Java program, create the source code forthe file, and copy the source code to a stream file, follow these steps:1. To create the source physical file for your Java program, a library in which to

save it is needed.

12 Getting Started with Java and AS/400: Java on AS/400

Page 19: Getting Started With Java and AS400- Java on AS400(Java400)

Note: On AS/400, libraries are not equivalent to directories. The system does not allow youto save a source physical file in a directory. You must save the file in a library.

Create a library. On the AS/400 command line, type:

CRTLIB LIB(mylib)

where mylib is the name of the library you are creating.

Press the Enter key.

A message appears at the bottom of your display, stating “Library created.”

2. Create the source physical file for your Java program. Type:CRTSRCPF FILE(mylib/myfile)

where mylib is the name of the library you created in the previous step andmyfile is the name of the file you are creating.

Note: When choosing a name for the source physical file, you do not have to follow Javafile naming conventions (for example, naming your Java application after the class that isinstantiated). The file you are creating here acts only as a receptacle for your Java sourcecode. You can create another file for the source code later.

Press the Enter key.

A message appears at the bottom of your screen, stating “File MYFILE createdin 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 copyyour source code to a stream file, you can save it in your directory.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Creating the Java source codeNow that you have created the source physical file, you need to add the code. Thispart of the setup uses PDM (Programming Development Manager) to create thecode and manipulate the file.1. Start PDM. On the AS/400 command line, type:

STRPDM

and press the Enter key.The AS/400 Programming Development Manager (PDM) screen appears.

2. The source code for your file is associated with a source member of the file.Create and edit the source member. Type 3 for Work with members and pressthe Enter key.The Specify Members to Work With display appears.

3. Fill out the display as shown below:File . . . . . . . . . . myfile

Library . . . . . . . . mylib

Chapter 4. Creating a Java application for your AS/400 13

Page 20: Getting Started With Java and AS400- Java on AS400(Java400)

where myfile is the name of the file you created, and mylib is the name of thelibrary in which you saved the file.

Press the Enter key.4. Press F6 to Create the file member.

Edit the source member. The Start Source Entry Utility (STRSEU) displayappears.

5. Fill out the display as shown below:Source file . . . . . . . . . . > myfile

Library . . . . . . . . . . . > mylibSource member . . . . . . . . . myclassSource type . . . . . . . . . . TXT

where myfile is the name of your Java program, mylib is the name of the libraryin which you saved it, and myclass is the name of the file member you arecreating.

Note: You may want to replace myclass with an abbreviated form of your Java class name.

Press the Enter key.

A message appears at the bottom of your display, stating “Member MYCLASSadded to file mylib/MYCLASS.” The SEU Edit display also reappears.

6. In the Edit display, without pressing the Enter key, type your Java programcode.Press the Enter key.The End of data line appears immediately below the line you typed.Press F3 to exit the Edit display.

7. Save the source member. The Exit screen appears. Fill out the display as shownbelow:Change/create member . . . . . . . Y

Member . . . . . . . . . . . . . myclassFile . . . . . . . . . . . . . . myfile

Library . . . . . . . . . . . . mylibPrint member . . . . . . . . . . . NReturn to editing . . . . . . . . . NGo to member list . . . . . . . . . N

where myclass is the name of your Java program, where myfile is the name ofyour physical source file, and where mylib is the name of the library in whichyou saved your file.

Press the Enter key.

The Work with Members Using PDM screen appears.8. Exit PDM by pressing F3 twice.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

14 Getting Started with Java and AS/400: Java on AS/400

Page 21: Getting Started With Java and AS400- Java on AS400(Java400)

Copying your Java code to a stream fileBefore you can compile and run your Java application, you must save it in adirectory in the integrated file system. To save your Java source code in a directory,you must copy the code to a stream file:1. On the AS/400 command line, type:

CPYTOSTMF

and press the F4 key.The Copy To Stream File (CPYTOSTMF) display appears.

2. Fill out the display as shown below:From database file member . . .

'/QSYS.LIB/mylib.LIB/myfile.FILE/myclass.MBR'To stream file . . . . . . . . .

'/mydir/myjavaclass.java'Stream file option . . . . . . . *NONEData conversion options . . . . *AUTODatabase file CCSID . . . . . . *FILEStream file code page . . . . . 819

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 Javaprogram, and replace myjavaclass with the class name of your Java application.

Note: See Name your Java application for more information on the Java file namingconvention.

Press Enter twice.

A message appears at the bottom of your screen, stating “Database file membercopied to object.”

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Stream fileAn AS/400 stream file is a file that contains a continuous stream of data, similar toUNIX and Windows files. The source physical file you created is a structuredAS/400 database file. To compile your AS/400 Java application, it must be in aformat the Java compiler recognizes, which is a stream file.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Chapter 4. Creating a Java application for your AS/400 15

Page 22: Getting Started With Java and AS400- Java on AS400(Java400)

Compiling your Java application from Qshell InterpreterTo compile and run your Java application on AS/400, use Qshell Interpreter. Qshellis a UNIX-like command entry environment on AS/400 that allows you to run thestandard Java commands (like javac and java) on your AS/400 system.

Follow these steps to compile your Java application:1. Make the directory that contains your Java application the current directory.

On the AS/400 command line, type:CHGCURDIR DIR(’/mydir’)

where mydir is the name of the directory in which you saved your Javaapplication.Press the Enter key.A message appears at the bottom of your screen, stating “Current directorychanged.”

2. Enter Qshell Command Entry. On the AS/400 command line, type:QSHand press the Enter key.The QSH Command Entry screen appears.3. Compile your Java application.On the Qshell command line, type:javac myclass.javawhere myclass is the name of your Java application.Press the Enter key.After your application is finished compiling, the shell prompt (by default, a $)appears, signalling that Qshell is ready for another command.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Optimizing your Java applicationOn AS/400, you have the option to optimize your Java application with the CreateJava Program command.

CRTJVAPGM creates a hidden service program, associated with your class file, thatimproves performance. CRTJVAPGM also has an OPTIMIZE parameter that allowsyou 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.

To optimize your Java application, complete these steps:1. In the QSH Command Entry screen, enter CL command entry by pressing F21

(Shift and F9).The command section of the QSH Command Entry screen is replaced with theCommand area.

2. On the Command line, type:CRTJVAPGM

and press the F4 key.The CRTJVAPGM (Create Java Program) display appears.

16 Getting Started with Java and AS/400: Java on AS/400

Page 23: Getting Started With Java and AS400- Java on AS400(Java400)

3. In the Class file or JAR file field, type:’/mydir/myclass.class’

where mydir is the path name of the directory in which your Java application issaved, and where myclass is the name of your compiled Java application.

Note: See AS/400 Developer Kit for Java documentation for more information about theparameters on the CRTJVAPGM command.

4. In the Optimization field, type 10.

Note: You can specify an optimization level of up to 40. An optimization level of 40increases the efficiency (i.e. running speed) of the Java application, but it also limits debugcapabilities. In the early stages of developing a Java application, you may want to set youroptimization level at 10 so you can more easily debug your application. See AS/400Developer Kit for Java documentation for more information.

5. Press the Enter key.A message appears, stating that a Java program has been created for your class.

6. Press F12 to exit CL command entry and return to Qshell.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Running your Java application from Qshell InterpreterTo run your Java application on your AS/400:1. On the Qshell command line, type:

java myclass

where myclass is the name of your compiled Java application.Press the Enter key.

2. Your Java application runs. After it is finished, the shell prompt (by default, a$) appears, signalling that Qshell is ready for another command.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Creating graphical applications with Java on AS/400If you are familiar with Java programming, you know that Java provides graphicaluser interface classes. Currently, the Swing and Abstract Window Toolkit (AWT)classes provide graphics for Java applications. However, AS/400 does not currentlysupport Java windowing graphics on locally-attached terminals or emulatorsessions.

AS/400 Developer Kit for Java features Remote AWT capabilities. With RemoteAWT configured on your AS/400 and a client workstation, the AWT graphics ofyour AS/400 Java application (running on your AS/400) can be displayed remotelyon your client workstation.

To set up Remote AWT, visit the AS/400 Developer Kit for Java documentation onsetting up Remote AWT.

Chapter 4. Creating a Java application for your AS/400 17

Page 24: Getting Started With Java and AS400- Java on AS400(Java400)

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

18 Getting Started with Java and AS/400: Java on AS/400

Page 25: Getting Started With Java and AS400- Java on AS400(Java400)

Chapter 5. Other information about Java and AS/400

Learn Java! Take a look at some Java education links. And, be sure to look at thislist of Java and AS/400 resources which points to books, manuals, websites,magazines, and newsgroups discussing Java on AS/400.

Internet applications, Java, and the AS/400 system

v Servlets Create servlets and put the web, Java, and AS/400 together.

v Building AS/400 Internet-Based Applications with Java shows how to designand build AS/400 Internet- or intranet-based Java applications, applets, andservlets. If you are interested in Java and AS/400’s e-business capabilities, thisredbook is for you. You will need Adobe Acrobat Reader to view this document.

Client/Server Java Links

v AS/400 Toolbox for Java product information. This is the online manual forAS/400 Toolbox for Java. Learn about the product features and how to usethem. The “Tips for Programming” section, in particular, provides important tipsfor writing Java applications that use AS/400 Toolbox for Java classes.

v AS/400 Toolbox for Java home page . Visit this site for information aboutusing AS/400 Toolbox for Java, troubleshooting, code updates, and downloads.

v Building AS/400 Client/Server Applications with Java (ITSO Redbook) featuresprojects and code examples using AS/400 Toolbox for Java. (You will needAdobe Acrobat Reader to view this document.)

Java on AS/400 Links

v AS/400 Developer Kit for Java product documentation. This is the online manualfor AS/400 Developer Kit for Java. Learn about the product features and how touse them.

v Java for RPG Programmers. Currently, this is the only AS/400-specificintroduction to Java. Even if you do not know RPG, you will still find the bookinvaluable for its description of Java in AS/400 terms.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Getting Started with Java and AS/400: ServletsServlets are Java applications that run on and interact with a Java-enabled webserver. Just as applets run in a browser’s Java virtual machine, servlets run in aweb server’s Java virtual machine.

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 reusableacross other server platforms.

© Copyright IBM Corp. 1998, 1999 19

Page 26: Getting Started With Java and AS400- Java on AS400(Java400)

The first step to getting started with servlets is to set up your web server with aJava runtime. To do this, install a Java application server on your AS/400. IBMWebSphere Application Server 2.03 for AS/400 comes free with V4R5 OS/400.

Setting up WebSphere Application Server

More servlet resources

v IBM WebSphere Application Server

v “Servlets: The New 5250 Model”

v Introduction to servlets on AS/400 (V4R3)

v JavaSoft Servlets . This site is Sun Microsystem’s home for Java Servlets.Check out the Servlet API (applied programming interface) and links to othernon-platform specific servlets resources.

v Servlet Central is an on-line “Server-side Java Magazine” which featuresarticles about servlet development. It has an extensive Resources section withlinks to other servlet information.

v WebSphere Application Server PTFs Lists the PTFs needed to ensureWebsphere runs correctly.

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Java and AS/400 resourcesIf you find a helpful Java and AS/400 source on the Internet that is not listed here,send us your comments.v Books (page 20)v Product documentation (manuals)v ITSO Redbooksv Magazines (page 21)v Internet sites (page 21)v Newsgroups, forums, and mailing lists

Note: See the Java education page for information about learning the Java programminglanguage.

Books

v Java for RPG Programmers by Phil Coulthard and George Farr of IBMToronto. Currently the only available AS/400-specific guide to Java, this book isextremely helpful for Java programming on AS/400. Also includes a MINQ Javatutorial CD-ROM, Introduction to Java Programming using VisualAge for JavaEnterprise.

Product documentation (manuals)

v AS/400 Developer Kit for Java

20 Getting Started with Java and AS/400: Java on AS/400

Page 27: Getting Started With Java and AS400- Java on AS400(Java400)

v AS/400 Toolbox for Java

v Qshell Interpreter

ITSO Redbooks

ITSO Redbooks

v Building AS/400 Applications with Java has examples of migrating RPGapplications to Java.

v Building AS/400 Client/Server Applications with Java features projects andcode examples using AS/400 Toolbox for Java.

Note: You will need Adobe Acrobat Reader to view this document.

v Building AS/400 Internet-Based Applications with Java shows how to designand build AS/400 Internet- or intranet-based Java applications, applets, andservlets. If you are interested in Java and AS/400’s e-business capabilities, thisredbook is for you.

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 Javanewsletter called Java Enterprise Solutions.

v Midrange Computing magazine . Since MC does not publish many of theirarticles on the Internet, you will probably want to get a subscription for thegood Java articles they frequently feature. You can also browse through andorder back issues for any good articles you might have missed. MC also

publishes the AS/400 NetJava Expert newsletter.

Internet sites

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 aboutAS/400 Toolbox for Java, including evaluation downloads, troubleshooting, andfrequently-asked questions.

v Qshell Interpreter home page provides references, downloads, andfrequently-asked questions about the Qshell Interpreter licensed program.

Chapter 5. Other information about Java and AS/400 21

Page 28: Getting Started With Java and AS400- Java on AS400(Java400)

v AS/400 Partners in Development Java page. The most comprehensive sitededicated to Java and AS/400, this home page features articles, demonstrations,solutions, resources, and information about “real world” Java implementationsby AS/400 business partners.

v IBM Centre for Java Technology Development. Visit this site from IBMHursley for Java news, information, free code downloads, and environmentsupport for all IBM platforms.

v IBM Java home page. Subtitled “The Ultimate Resources for JavaDevelopers,” 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 IBM SanFrancisco home page. IBM SanFrancisco is a Java-based collectionof business application components that allows you to assemble server-sideapplications from pre-existing parts. The SanFrancisco home page providesinformation and resources about the project.

v VisualAge for Java and AS/400 home page. If you are interested in what anintegrated development environment (IDE) like VisualAge for Java can do foryour Java and AS/400 programming, see this site.

Newsgroups, forums, and mailing lists

Newsgroups

v IBM Hursley AS/400 Java Environment newsgroup

v AS/400 newsgroup

Forums

v IBM Hursley AS/400 Java Environment forum

v Midrange Computing Java Programming Discussion forum

v News/400 Java forum

Mailing lists

v MIDRANGE dot COM JAVA/400 mailing list

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Java educationLearning Java does not have to be expensive. You can find several good Javatutorials on the Internet as well as other materials like books and articles.

Listed below are some good resources for learning about Java programming. Seeboth 22 and 23 links.

22 Getting Started with Java and AS/400: Java on AS/400

Page 29: Getting Started With Java and AS400- Java on AS400(Java400)

See Java and AS/400 resources for other links that will be helpful in your Javaeducation. AS/400-specific Java education

v AS/400 Partners in Developer Java Education features AS/400-specific Javaeducation such as books, Internet-based courses, classroom training, andworkshops.

v This course is part of the IBM Education and Training AS/400 Curriculum.

v NEWS/400’s Java Tutorial features a collection of articles written by Javaand AS/400 experts Phil Coulthard and George Farr.

v Java for RPG Programmers by Phil Coulthard and George Farr of IBMToronto. Currently the only available AS/400-specific guide to Java, this book isextremely helpful for learning Java programming for AS/400. The book alsoincludes a MINQ Java tutorial CD-ROM, Introduction to Java Programming usingVisualAge for Java Enterprise.

General Java education

v IBM Java Education includes online courses, classroom training, whitepapers, tutorials, articles, books, and FAQs.

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 theJava« 2 Platform software to create and run three common types of programswritten for the Java platformùapplications, applets, and servlets. (SunMicrosystems, Inc.)

[ Information Center Home Page |Feedback ]

[ Legal | AS/400 Glossary ]

Chapter 5. Other information about Java and AS/400 23

Page 30: Getting Started With Java and AS400- Java on AS400(Java400)

24 Getting Started with Java and AS/400: Java on AS/400

Page 31: Getting Started With Java and AS400- Java on AS400(Java400)
Page 32: Getting Started With Java and AS400- Java on AS400(Java400)

����

Printed in U.S.A.