C H A P T E R  1

Getting Started

This chapter explains what you must do before starting the Forte for Java, Community Edition tutorial. For your convenience, it duplicates some installation information from the Forte for Java 4 Getting Started Guide. The topics covered in this chapter are:



Note - There are several references in this book to the CDShopCart application files. These files include a completed version of the tutorial application, a Readme file describing how to run the completed application, and several versions of the SQL script for creating the required database table. These files are compressed into a ZIP file you can download from the Forte for Java 4 Developer Resources portal at http://forte.sun.com/ffj/documentation/tutorialsandexamples.html




Software Requirements for the Tutorial

This section describes how to prepare your system before starting the Forte for Java 4, Community Edition tutorial. This means making sure you have everything required to run the Forte for Java 4 integrated development environment (IDE), as well as what is required to create and run the tutorial.

You can access general system requirements from the release notes or from the Forte for Java Developer Resources portal's Documentation page at http://forte.sun.com/ffj/documentation/.

What You Need to Run the Forte for Java 4 IDE

The Forte for Java 4 IDE requires the Javatrademark 2 Platform, Standard Edition (the Java 2 SDK). When you install the IDE, the installer searches your system for the Java 2 SDK software and will notify you and stop the installation if the correct version is not installed on your system. You can download the correct version of the Java 2 SDK from the Java Developer's portal at http://java.sun.com/j2se/.

What You Need to Create and Run the Tutorial

You need the following items to create and run the tutorial. Some of these items are included in the default installation of Forte for Java 4, Community Edition. For the supported versions of these products, see the release notes on the following web site: http://forte.sun.com/ffj/documentation/index.html

You can install PointBase when you install Forte for Java 4, Community Edition. To see whether PointBase was installed, look for a pointbase directory under the directory where Forte for Java 4 is installed. If no pointbase directory is there, you can run the installer again to install it.
The tutorial SQL scripts are provided in Appendix B. They are also included in the application files of the CDShopCart tutorial, available from the Forte for Java 4 Developer Resources portal. See Creating the Tutorial Database Table for information on installing the tutorial database table.
The tutorial is a web application, which requires a web server. This tutorial uses an embedded version of Tomcat, version 4.0, within the IDE that provides the functionality of a web server for testing purposes.
You need a web browser to view the tutorial application pages. This can be either Netscape Communicatortrademark or Microsoft's Internet Explorer. Netscape Communicator is available for download from the Forte for Java Developer Resources portal or the product CD.


Starting the Forte for Java 4 IDE

Start the Forte for Java 4 IDE by running the program executable, as described in the following sections, and more fully in the Forte for Java 4 Getting Started Guide.

Starting the IDE on Solaris, UNIX, and Linux Environments

After installation, a runide.sh script is in forte4j-home/bin directory. Launch this script by typing the following in a terminal window:

$ sh runide.sh

For ways to customize this script, see Modifying the Session With Command-Line Switches.

Starting the IDE on Microsoft Windows

After installation, start the IDE in one of the following ways:

single-step bulletDouble-click the Forte for Java 4.0 CE icon on your desktop.

This runs the runidew.exe executable, which launches the IDE without a console window. This executable exists in the forte4j-home\bin directory, along with an alternative executable--runide.exe. The runide.exe icon launches the IDE with a console window that includes standard error and standard output from the IDE. On the console, you can press Ctrl-Break to get a list of running threads or Ctrl-C to immediately terminate the program.

single-step bulletChoose Start right arrow Programs right arrow Forte for Java 4.0 CE right arrow Forte for Java CE.

single-step bulletRun any of the executables from the command line.

For example:

C:\> runide.exe [switch]

See the next section for information on switches.

Modifying the Session With Command-Line Switches

TABLE 1-1 describes the switches that you can use to modify how you launch the IDE. This information is also available from the Forte for Java 4 Getting Started Guide, but is provided here for your convenience.

  • On Microsoft Windows systems
You can set options when running the IDE on the command line.
  • In Solaris, Linux, and other UNIX environments
You can modify the ide.sh file in the bin subdirectory of the installation directory, or you can create your own shell script that calls ide.sh with options.
TABLE 1-1 runide Command-Line Switches

Switch

Meaning

-classic

Uses the classic JVM.

-cp:p addl-classpath

Adds a class path to the beginning of the Forte for Java 4 class path.

-cp:a addl-classpath

Adds a class path to the end of the Forte for Java 4 class path

-fontsize size

Sets the font size used in the GUI to the specified size.

-locale language [:country[:variant]]

Uses the specified locale for the session instead of the default locale.

-Jjvm-flags

Passes the specified flag directly to the JVM. (There is no space between -J and the argument.)

-jdkhome jdk-home-dir

Uses the specified Java 2 SDK instead of the default SDK.

-h or -help

Opens a GUI dialog box that lists the command-line options.

-hotspot or -client or -server or
-classic or -native or -green

Uses the specified variant of JVM.

-single

Runs the IDE in single-user mode. Enables you to launch the IDE from forte4j-home instead of from your user settings directory.

-ui UI-class-name

Runs the IDE with the given class as the IDE's look and feel.

-userdir user-directory

Uses the specified directory for your user settings for the current session. See the next section for more information.


Specifying Your User Settings Directory

The Forte for Java 4 IDE stores your individual projects, samples, and IDE settings in your own special directory. This enables individual developers to synchronize their development activities, while keeping their own personal work and preferences separate.

  • In Solaris, UNIX, or Linux environments
If you don't explicitly specify a user settings directory with the -userdir command-line switch, user settings are located by default in user-home/ffjuser40ce.
  • On Microsoft Windows systems
At first launch of the Forte for Java 4 IDE, you are prompted to specify a user settings directory. Use a complete specification, for example, C:\MySettings.

Forte for Java IDE dialog box for Microsoft Windows showing sample directory specification. The buttons are OK and Cancel. 

This value is stored in the registry for later use. For a given session, you can specify a different user settings directory by using the -userdir command-line switch when launching the IDE.


Understanding the Forte for Java 4 Directory Structure

When you install the Forte for Java 4 software, the subdirectories described in TABLE 1-2 are included in your installation directory.

TABLE 1-2 Forte for Java 4 Directory Structure

Directory

Purpose

beans

Contains JavaBeanstrademark components installed in the IDE.

bin

Includes Forte for Java 4 launchers (as well as the ide.cfg file on Microsoft Windows installations).

docs

Contains the Forte for Java 4 help files and other miscellaneous documentation. (Release notes are found under forte4j-home.)

iPlanet

Contains files used by the iPlanet plug-ins.

j2sdkee1.3.1

Contains the J2EE Reference Implementation, if installed.

javadoc

The directory mounted by default in the IDE's Javadoc repository. Both Javadoc provided with the IDE and user-created Javadoc are stored here.

lib

Contains JAR files that make up the IDE's core implementation and the open APIs.

modules

Contains JAR files of Forte for Java 4 modules.

pointbase

Contains the executables, classes, databases, and documentation for the PointBase Server 4.2 Restricted Edition database (if installed).

sampledir

Contains source files and readme files for several examples.

sources

Contains sources for libraries that might be redistributed with user applications.

system

Includes files and directories used by the IDE for special purposes. Among these are ide.log, which provides information useful when seeking technical support.

tomcat401

Contains sources for the Tomcat, 4.01, web server.


When you launch the Forte for Java 4 software, the subdirectories in TABLE 1-3 are installed in your user settings directory. Most of them correspond to subdirectories in the Forte for Java 4 home directory, and are used to hold your settings.

TABLE 1-3 Directory Structure for the User Settings Directory

Directory

Purpose

beans

Contains user settings for JavaBeans components installed in the IDE.

javadoc

Contains user settings for Javadoc files installed in the IDE.

lib

Contains user settings for the system lib files.

modules

Contains modules downloaded from the Update Center.

sampledir

The directory mounted by default in the Filesystems pane of the Explorer. Objects you create in the IDE are saved here unless you mount other directories and use them instead.

sampledir/examples

Contains several NetBeans example applications.

SunONE

Contains user settings for the iAS application server.

system

Contains user settings for system files and directories.

tomcat401_base

Contains user settings for your work with JSP pages.



Verifying the Correct Default Web Server

The CDShopCart tutorial uses the Tomcat 4.0 web server. This server is installed and set as the default web server by the Forte for Java 4 installer. However, you should verify that Tomcat is the default server before you test or run the CDShopCart application.

To verify that the Tomcat web server is the default server:

1. In the Forte for Java 4 IDE, click the Explorer's Runtime tab.

2. Expand the Server Registry node and its Default Servers subnode.

  • If the Default Servers node looks like this, then the IDE is using the correct server.

Segment of Runtime pane of Explorer showing the Default Servers node with the default web server as Tomcat 4.0[Internal:localhost]. 

  • If anything other than Tomcat 4.0 is listed, then:

a. Right-click the default web server node and choose Set Default Server.

The Select Default Web Server dialog box is displayed.

b. Select the correct server and click OK.


Creating the Tutorial Database Table

Before you start the Forte for Java 4, Community Edition tutorial, you must create and install a database table. Instructions in this section describe how to install the table in a PointBase database. If you wish to use a different database program, other versions of the tutorial SQL script are provided in Appendix B.

Alternatively, files containing the SQL script are included in the zip file of the tutorial source code, which you can download from the Forte for Java Developer Resources portal at:

http://forte.sun.com/ffj/documentation/tutorialsandexamples.html

TABLE 1-4 identifies the four available SQL script files.

TABLE 1-4 SQL Scripts for Creating the Tutorial Table

Script name

Description

CDCatalog_pb.sql

Creates and populates the table used by the tutorial in PointBase SQL format. Contents are in Script for a PointBase Database.

CDCatalog_ora.sql

Creates and populates the table used by the tutorial in Oracle SQL format. Contents are in Script for an Oracle Database.

CDCatalog_ms.sql

Creates and populates the table used by the tutorial in Microsoft SQLServer SQL format. Contents are in Script for a Microsoft SQLServer Database.

CDCatalog_db2.sql

Creates and populates the table used by the tutorial in IBM DB2 SQL format. Contents are in Script for an IBM DB2 Database.


The CDCatalog script creates the database schema shown in TABLE 1-5.

TABLE 1-5 CDCatalog Database Table

Table Name

Columns

Primary Key

Other

CD

id

yes

 

cdtitle

 

 

artist

 

 

country

 

 

price

 

 


The CD table is populated with the records shown in TABLE 1-6.

TABLE 1-6 CD Table Records

ID

CDtitle

Artist

Country

Price

1

Yuan

The Guo Brothers

China

14.95

2

Drums of Passion

Babatunde Olatunji

Nigeria

16.95

3

Kaira

Tounami Diabate

Mali

13.95

4

The Lion is Loose

Eliades Ochoa

Cuba

12.95

5

Dance the Devil Away

Outback

Australia

14.95


First create a tutorial database and load the table into it. (If you prefer, you can install the table in any PointBase database you choose.)



Note - If you have already started the Forte for Java IDE, you can either leave it running while you create your database tables, or quit and restart after you finish.



To create the tutorial database table:

1. Start the PointBase Server.

  • In Solaris or Linux environments: Run the Server file in the forte4j-home/pointbase/server directory.
  • On Microsoft Windows: Choose Start right arrow Forte for Java 4.0 CE right arrow PointBase right arrow Server or double-click the server.bat file in the forte4j-home/pointbase/server directory.

2. Start the PointBase Console.

  • In Solaris or Linux environments: Run the Console file in the forte4j-home/pointbase/client directory.
  • On Microsoft Windows: Choose Start right arrow Forte for Java 4.0 CE right arrow PointBase right arrow Console or double-click the console.bat file in the forte4j-home/pointbase/client directory.
The Connect To Database dialog box appears, showing values for the PointBase driver to the default sample database.

3. Change the word sample at the end of the URL field to cdshopcart, as shown.

PointBase's Connect To Database dialog box showing the example values entered.[ D ] 

4. Set the Create New Database option and click OK.

The PointBase Console is displayed. Wait until the status message ending in "Ready" is displayed before proceeding.

5. Copy the PointBase script from Script for a PointBase Database and paste it into the SQL entry window of the Console.

Alternatively, if you have the CDCatalog_pb.sql file from the tutorial source zip file, do this:

a. Choose File right arrow Open to display the file browser dialog box.

b. Use the file browser to find the CDCatalog_pb.sql file and click Open.

6. Choose SQL right arrow Execute All.

The message window confirms that the script was executed. (Ignore the initial messages beginning "Cannot find the table..." These appear because there is a DROP statements for the table, which has not been created yet. This DROP statement will be useful in the future if you want to rerun the script to initialize the table.)

Two database files are created in the forte4j-home/pointbase/databases directory.

7. Test that you have created the table by clearing the SQL entry window (Window right arrow Clear Input) and typing:

SELECT * FROM CD;

8. Choose SQL right arrow Execute.

Your console should display the CD table.



Note - If your display does not look like this table, choose Window right arrow Windows to change the display type.



PointBase console showing the example select statement as input and the CD table and its data as output.

9. Close the PointBase Console window.

Now, you are ready to start the tutorial.