C H A P T E R  1

Getting Started

This chapter explains what you must do before starting the Sun ONE Studio 4, Community Edition tutorial. For your convenience, it duplicates some installation information from the Sun ONE Studio 4, Community Edition 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 Sun ONE Studio 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 Sun ONE Studio 4, Community Edition tutorial. This means making sure you have everything required to run the Sun ONE Studio 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 Sun ONE Studio 4 Developer Resources portal's Documentation page at http://forte.sun.com/ffj/documentation/.

What You Need to Run the Sun ONE Studio 4 IDE

The Sun ONE Studio 4 IDE requires the Javatrademark 2 Software Development Kit (the J2SEtrademark SDK). When you install the IDE, the installer searches your system for the J2SE 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 J2SE 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 Sun ONE Studio 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 Sun ONE Studio 4, Community Edition. To see whether PointBase was installed, look for a pointbase directory under the directory where Sun ONE Studio 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 Sun ONE Studio 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.


Starting the Sun ONE Studio 4 IDE

Start the Sun ONE Studio 4 IDE by running the program executable, as described in the following sections, and more fully in the Sun ONE Studio 4, Community Edition Getting Started Guide.

Starting the IDE on Microsoft Windows

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

single-step bulletDouble-click the Sun ONE Studio 4 CE icon on your desktop.

This runs the runidew.exe executable, which launches the IDE without a console window. This executable exists in the s1studio-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 Sun Microsystems right arrow Sun ONE Studio 4 CE right arrow Sun ONE Studio

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

For example:

C:\> s1studio-home\bin\runide.exe [switch]

For information on switches, see Modifying the Session With Command-Line Switches.

Starting the IDE on Solaris, UNIX, and Linux Environments

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

$ sh s1studio-home/bin/runide.sh

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 Sun ONE Studio 4, Community Edition 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, UNIX, and Linux 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 Sun ONE Studio 4 class path.

-cp:a addl-classpath

Adds a class path to the end of the Sun ONE Studio 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 s1studio-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 Sun ONE Studio 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 Sun ONE Studio 4 IDE, you are prompted to specify a user settings directory. Use a complete specification, for example, C:\MySettings.

Sun ONE Studio 4 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 Sun ONE Studio 4 Directory Structure

When you install the Sun ONE Studio 4 software, the subdirectories described in TABLE 1-2 are included in your installation directory.

TABLE 1-2 Sun ONE Studio 4 Directory Structure

Directory

Purpose

_uninst

Contains the files used to uninstall the IDE.

beans

Contains JavaBeanstrademark components installed in the IDE.

bin

Includes Sun ONE Studio 4 launchers (as well as the ide.cfg file on Microsoft Windows installations).

(Solaris only) Also contains launch points for the standalone applications delivered with the Solaris tools, including xemacs, gvim, xdesigner, and forte_fcc.

docs

Contains the Sun ONE Studio 4 help files and other miscellaneous documentation.

emacs

(Solaris only) Contains emacs files.

examples

Contains source files for examples that illustrate several key features of the Sun ONE Studio 4, Enterprise Edition for Java.

j2sdkee1.3.1

(English-only installation) Contains the Java 2 Platform, Enterprise Edition (J2EEtrademark SDK) v. 1.3.1, if you chose to install it during the Sun ONE Studio 4 installation process.

lib

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

man

(Solaris only) Contains man pages for Solaris Developer Modules, if installed.

modules

Contains JAR files of Sun ONE Studio 4 modules.

pointbase

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

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 Sun ONE Studio 4 software, the subdirectories in TABLE 1-3 are installed in your user settings directory. Most of them correspond to subdirectories in the Sun ONE Studio 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.

j2sdkee1.3.1

Contains the Java 2 Platform, Enterprise Edition (J2EEtrademark SDK) v. 1.3.1, if you chose to install it during the Sun ONE Studio 4 installation process.

lib

Contains user settings for the system lib files.

modules

Contains modules downloaded from the Update Center.

pointbase

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

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.

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 Sun ONE Studio 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 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 Sun ONE Studio 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 Sun ONE Studio 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.)

To create the tutorial database table:

1. Start the IDE, if you have not already started it.

2. Start the PointBase Server by choosing Tools right arrow PointBase Network Server right arrow Start Server.

A PointBase Server dialog box is displayed. Minimize the dialog box window.

3. Start the PointBase Console.

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

4. 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 ] 

5. 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.

6. 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.

7. 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 s1studio-home/pointbase/databases directory.

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

SELECT * FROM CD;

9. Choose SQL right arrow Execute.

Your console should display the CD table.

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


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



10. Close the PointBase Console window.

Now, you are ready to start the tutorial.