Working with projects

To develop programs in the JBuilder environment, you must first create a project. A project organizes the files and maintains the settings that make a JBuilder application or applet. You can view and manage your project in the project pane.

A JBuilder project is an organizational tool. When you put a file into a JBuilder project, it doesn't change that file's location in your directory structure. This means you can use the same file in any number of JBuilder projects without ever moving the file. You can view and manage your directory structure using your favorite file management tool.

The information about a JBuilder project is stored in a project file. The project file includes the list of files and packages that are in the project and the project properties that define the project. JBuilder uses this information when you load, save, build, or deploy a project. You don't edit the project file directly; it is modified whenever you use the JBuilder development environment to add or remove files or to set project properties such as paths or connection settings.

The project file is shown as a node in the project pane. Listed below it are all the files in the project:

Saving projects

While you are working on a project, you can save it to the default location or to a directory of your choice. By default, JBuilder saves projects to the jbproject directory of your home directory.

Each project is saved to its own directory. Each project directory includes a project file (.jpr or .jpx), an optional file for project notes (.html), a classes directory for class files, a src directory for source files, and a bak directory for backup copies of your files.

By default, the project directory (with its children) is saved to jbproject. All paths can be changed in the Project wizard and in the Project|Project Properties dialog.

For more information on the location of the jbproject and home directories, see the Platform conventions and directories table in "Documentation conventions" in the Introduction.


Using the Project wizard

JBuilder includes a Project wizard that simplifies project creation. When you use the Project wizard to create a new project, the wizard automatically sets up the directory framework for the project and develops and saves information on project properties, such as applicable paths and JDK version. You may also create a project notes file. The information in this file can go into the commentary of the source files the project contains, and from there into any JavaDoc-generated documentation you create from that project.

If you use the Application or Applet wizard without any projects open, the Project wizard is launched first so you can create a new project to hold the new application or applet.

For more information on the Project wizard, click the Help button in the wizard's dialog box. For more information about the Application or Applet wizards, select File|New, choose the Application or Applet icon from the object gallery, and click Help in the wizard's dialog box.

Project wizard: Step 1

Step 1 sets the names of the files associated with the project. It also sets the root path and the project template.

To create a new project with the Project wizard, Choose File|New Project to open the Project wizard. This will bring up Step 1 of 3:

Project wizard-Step 1

  1. Enter the project name.
  2. Select the project file type: .jpr or .jpx.
    To read about file types in JBuilder, see "File types in a JBuilder project" in "Creating and Managing Projects" in Building Applications with JBuilder.
  3. Choose a project template. You can choose from the drop-down list of previously opened projects, or you can click the ellipsis (...) to browse to a project you want to use as a template.
    Note: You can add files at any time by selecting the Add Files/Packages icon from the project toolbar.
  4. Set the root path. You may choose from the drop-down list or click the ellipsis to browse.
  5. Enter the name of the project directory.
  6. If you don't wish to accept the default names, set the names of the source directory, the backup directory, and the output directory.
  7. Choose whether you want the project directory to be the parent to the source and output directories. If you leave this unchecked, JBuilder will automatically put the project and class files into separate directories off of the root path. You can edit your paths later in the wizard.
  8. Click Next. Step 2 of the Project wizard appears.

Project wizard: Step 2

Step 2 sets the paths the project will use, the JDK version to compile against, and the libraries the project will require. Step 2 is where you can tell JBuilder whether to make a project notes file.

Project wizard-Step 2

  1. Check the project, source, backup, and output paths. The information that you set in Step 1 shows up here.
    JBuilder defaults all of these paths to the jbproject directory, but you can change them here to suit your development needs.
  2. Set the version of the JDK that you will compile against. Click on the ellipsis (...) to bring up the Select A JDK dialog.
  3. Choose the libraries the project will require. Click Add to bring up the Select One Or More Libraries dialog. This dialog allows you to sort the library list, select single or multiple libraries, create new libraries, and edit or delete existing libraries.
  4. Decide whether you want a project notes file.
    If not, uncheck this box and click Finish. You're done!
    If so, leave the box checked and click Next in order to create this file. Step 3 of the Project wizard appears.

Project wizard: Step 3

Step 3 develops the project notes file. These project notes are the basis of the About box of the application you create.

Project wizard-Step3

  1. Enter the project's title, author or authors, and company name. Write a project description in the pane below.
  2. Click Finish. You're done!
The newly created project node appears at the top of the project pane with the HTML notes file below it. To view your paths, JDK, and libraries, right-click on the project node, select Properties, and select the Paths tab. To view your project notes information as JavaDoc class fields, select the General tab in the same dialog.

For more information on projects and the Project wizard, see "Creating and managing projects" in Building Applications with JBuilder. For a tutorial on creating a project and an application, see "Tutorial: Building an application."


Displaying project files

JBuilder displays the project file in the project pane of the AppBrowser. The files that make up the project are listed below it. To open a file in the content pane, double-click its name in the project pane.
Note: You can only view one file at a time in the content pane. To view multiple files simultaneously, open multiple instances of the AppBrowser. To do so, select Window | New Browser for each instance desired.

A tab with the file name appears at the top of the content pane. If several files are open, there will be a file tab for each one. You can look at a different open file by selecting its file tab or by selecting the file from the Window menu. You can customize the labeling and positioning of the file tabs. To learn about customizing your file tabs, see the "File Tabs" topic in "The JBuilder Environment" in Building Applications with JBuilder.

The following figure shows a project file, hello.jpr, in the project pane with the source and image files listed below it. The project notes file, hello.html, is selected in the content pane. The project notes are created from the information entered in Step 3 of the Project wizard.


Setting project properties

Project properties control the following:

Note: The project properties options vary by JBuilder edition.

You can set the properties for your project by right-clicking a .jpr or .jpx project file in the project pane and then selecting Properties or by choosing Project|Project Properties.

On the Paths page of the Project Properties dialog box you can specify:

You can also globally set the default properties for all new projects in the Default Project Properties dialog box (Project|Default Project Properties).

For more information, see the "Setting project properties" topic in "Creating and managing projects" in Building Applications with JBuilder.


Managing projects

From the AppBrowser, you can:

Opening projects

To open a project, select File|Open Project and browse to find the project file you want. To open a previously opened project, select File|Reopen and select the project file from the drop-down list. Or click the Open Open or Reopen Reopen buttons on the main toolbar.

Adding and removing files

You can add and remove files and packages from a project or folder by using the Add Files/Packages Add To Project or the Remove From Project Remove From Project buttons on the project toolbar, or by right-clicking on a file in the project pane and selecting Add Files/Packages or Remove From Project from the right-click menu.

Right-click menu

The Add Files/Packages dialog has two tabs: Packages, which shows a list of available packages, and Explorer, which allows you to browse your directories and files.

Add Files/Packages Explorer view

Tip: You can create a new file from the Explorer page by entering a new file name and clicking OK. You will get a message asking if you want to create that file; click OK.

Saving and closing projects

To save a project, select File|Save All, File|Save Current Project, or click the Save All button on the main toolbar.

To close a project, select File|Close Project, File|Close Files, or click the Close Project button on the project toolbar.

Renaming projects and files

To rename a project,
  1. Select the project in the project pane.
  2. Select Project|Rename.
  3. Enter the new name in the File Name field of the Rename dialog box.
  4. Click OK.
To rename an open file,
  1. Select File|Rename or right-click on the file tab at the top of the content pane and select Rename.
  2. Enter the new name in the File Name field of the Rename dialog box.
  3. Click Save.

Caution: Renaming projects and files does not change the references to the relevant package and file names inside the code.

Working with multiple projects

When working with multiple projects, you can open them in one instance of the AppBrowser or in different instances. All open projects are available from any open AppBrowser instance. However, you can only view the files of one project at a time in each AppBrowser instance.

There are several ways to switch between multiple open projects and files:

For more information, see "Creating and managing projects" in Building Applications with JBuilder.