TOC PREV NEXT INDEX DOC LIST MASTER INDEX



Editing, Compiling, and Executing a Java Program

This section explains how to:


Create a Java file

All code must be in a subsystem and view (text). A Java applet is not a standalone Java application; it runs within an applet viewer or a Web browser such as Netscape.

1. . Create a subsystem named project2.ss.

2. . Create a Java view named java.wrk.

A directory viewer window (graphics) with the project2.ss/java.wrk view is displayed.

3. . Create a Java file using the File:New:New Java command.

Apex displays the New Java dialog box (graphics). Notice that the pathname of the java.wrk view appears in the Context field.

4. . Set the dialog box values to create the java applet in the circle.java file.

5. . Select the OK button in the New Java dialog box (graphics).

6. . Apex creates a Java file named circle.java and displays it in a Java editor (graphics) window.



Edit the Java applet

Enter the java applet:


Code the Java applet

Compile the Java applet to generate the .class file.

1. . Select the Compile:Code command

The Jobs window for the code command (graphics) is displayed.

The Message window for the code command (graphics) is displayed.

The class is displayed in the project2.ss/java.wrk directory viewer (text) in the form circle.class.



Create the associated HTML file

Because the Java program is an applet, you need to display an HTML file that references the applet in a Web browser. The Web browser runs the Java interpreter internally to interpret the applet's compiled code that is in the .class file.

1. . Create an HTML file using the File:New:New HTML command

Apex displays the New HTML dialog box (graphics). Notice that the pathname of the java.wrk view appears in the Context field.

2. . Set the dialog box values to create the HTML file in the circle.html file.

3. . Select the OK button in the New HTML dialog box (graphics).

Apex creates an HTML file named circle.html and because Visit it is selected, displays the file in an HTML editor (graphics) window. The file is created with the HTML code to run circle.class. Do not modify this file.



Run the Java Applet

To run the circle.java applet, you will open the associated HTMLfile in a Web browser.

1. . Open the circle.html file in a Web browser.

2. . Enter a number between 1 and 200 in the text field in circle applet.

3. . Select the Display Circle button.

A circle with your radius is displayed.

4. . Exit the Web browser.


You have just completed the Quick Start Java Tutorial. To delete the files you have created, visit the Cleaning Up topic.


Rational Software Corporation 
http://www.rational.com
support@rational.com
techpubs@rational.com
Copyright © 1993-2001, Rational Software Corporation. All rights reserved.
TOC PREV NEXT INDEX DOC LIST MASTER INDEX TECHNOTES APEX TIPS