Setting the Class Path

In VisualAge for Java, each runnable class is responsible for its own class path. The class path is necessary when running a class in order for the class loader to properly find the classes that your class references and the classes that they in turn reference.

You can specify a workspace-level class path that every class will get use it is run (similar to traditional CLASSPATH environment variables). This class path is also needed to find resource files your classes use. The workspace class path is set from the Resources page in the Options notebook.

In addition, each class must have a class path associated with it in order to run.   Typically the class path needs to include every project (directory) containing classes the runnable class references or resources it uses. To set the class path for a class:

  1. Select the class.
  2. Select Properties from the class's pop-up menu.
  3. Click the Class Path tab in the Properties notebook.

Or:

  1. Select the class.
  2. From the class's pop-up menu, select Run, Check Class Path.

Both of these methods open the class's properties notebook to the Class Path page.

The class path tab contains the following three-part definition for the class path:

The class path for your class is formed by concatenating these three settings plus the workspace  path.

Once you have configured your class path you can save it locally (for example, if you are experimenting with a class) or you can save it into the repository.  If you do not save it to the repository, then the information is only in your workspace.

To save the class path settings to the repository, enable the Save in repository (as default) checkbox  before clicking OK.  

tentergf.gif (577 bytes)  Once it is saved into the repository anyone else loading your class can then pick up those settings as the default.

Important! When you export a project or package, the class path information stored with the class in the repository is used. Any class path values stored only in your workspace are not exported. 

For any class, to retrieve the default class path settings that are saved in the repository, click the Defaults button.

Debugging External Classes
The debugger settings in the Options dialog include a class source path, in which you can set the path to source code for the external classes used by your application.  This allows you to step into methods in external classes when you debug.  Set the debug source path on the Debugging page of the Options dialog.

Setting the Class Path for Classes that Use JFC
If you created a class and wrote code for it that uses JFC, then you must update the class path for it to include the path to the JFC project directory.   Otherwise, the class will not run.

To update the class path:

  1. Select the class in a browser.
  2. From the class's pop-up menu, select Run, Check Class Path.   This will open the class Properties notebook to the Class Path page.
  3. Next to the Project Path field, click Compute Now.   The JFC project path will be added. 
  4. Enable the Save to Repository (as default) check-box.
  5. Click OK.

ngrelt.gif (466 bytes)
Loading External Classes Dynamically
Setting IDE Options