JBuilder

We used the JBuilder Foundation version 3.5. Check www.inprise.com

for further information and free downloading.

Creating the Project in JBuilder

After opening JBuilder, click on the File menu and then New Project to create a project which will contain all the files used in the given applet or application. Enter a file name for the project in the Project File field and click Finish. We demonstrate with Example 1.1, so we will call our project ex1_1, and enter d:\ex1_1\ex1_1.jpr. All files for the project will be in the D:\ex1_1 directory.If the project files are in a package, use the package name as the directory name.

The left pane shows the files in the project. JBuilder includes a default HTML file, ex1_1.html. Since our first program is an application, remove this HTML file by highlighting it and clicking the minus (-) button just above the file list.

Adding a Program to the Project in JBuilder

To add the Hello.java program of Example 1.1 to the project:

Click on the plus (+) button above the left pane, which pops up a file dialog.

Browse in the file dialog to find Hello.java, and open it.

To compile Hello.java:

Click on File, Project, Project Properties tab.

Click on the Add button to select the directory containing the Hello.java and click OK. This

allows the compiler to find the source file.

Click on the Project, Make Project "ex1_1.jpr" menu item.

Running the project in JBuilder

To run the program:

Click on the Run, Debug project menu item. The first time we run the program a Runtime properties window pops up. Press the Set button to choose the class file containing the main method. In this example we choose Hello. Click OK.

The output appears in the text area.

Applets in JBuilder

We use Example 1.2 HelloApplet.java to illustrate running an applet in JBuilder.

Make a project, say ex1_2.jpr, as shown above for ex1_1.

Remove ex1_2.html from the project by clicking on it and clicking the minus (-) button.

Add HelloApplet.java to the project as shown above for Hello.java.

Compile HelloApplet.java as shown above for Hello.java.

Click on Run, Debug project. The first time we run the program a Runtime properties window pops up. Click on the Applet tab and press the Set button to choose the class file for the applet. In this example we choose HelloApplet. Enter the height and width. Click OK.

The applet screen appears.

Importing User-Defined Packages in JBuilder

The Project Properties defaults are set to allow the compiler to find the standard Java classes. To run programs such as Example 1.5 AtmScreen.java that use our own packages from the text follow the instructions for compiling. Add the directories containing each of the packages to the source:

Click on Project, ProjectProperties, Paths, Required Libraries tab.

Click on the Add button, and the New button. In the Edit window that pops up, click on the Add button, selecting the directory that contains the package directory (not the package directory itself).

Enter the package name in the Name field and click OK. Click OK.

Click OK.

Repeat these steps for each user-defined package used. For the AtmScreen example we need the personData package, and add the directory which contains the personData directory.

Passing Program Arguments in JBuilder

To run a program such as Example 10.11, ReadFileLines.java, which uses program arguments, follow the steps for a console application, and to pass the arguments to the program:

Click on Project, Project Properties, Run tab.

Add the arguments in the Application Parameters field and click OK.

Creating a New Program in JBuilder

Follow the steps for working with an existing program, but in the file dialog that pops up after clicking on the plus(+) button to add a file to the project:

Enter the file name of the file to be created in the File name field and click on Open.