How does VAJ handle compile time and runtime classpath? How do I specify the classpath and/or use third-party libraries in VAJ?

Jim Sculley

VAJ has two 'classpaths'. One at compile time, and another at runtime.

The compile time classpath includes everything that is in the Workspace. In other words, the compiler knows about all the classes in the Workspace, but knows nothing about classes in the Repository, or outside the VAJ application. In other words, to enable the VAJ compiler to recognize classes, they must be imported into VAJ - you cannot direct the VAJ compiler to external JAR files that aren't in the IDE.

The runtime classpath for a runnable class (application or applet) includes, by default, only the classes in the project where the class is located, and any classes listed in the Workspace Classpath (under the 'Window...Options..Resources' menu item). If the application/applet uses some classes that are in other Projects, you will have to edit its runtime classpath to include those Projects.

The term 'Workspace Classpath' is somewhat misleading, because it really refers to the runtime classpath for all classes in the Workspace. It doesn't have anything to do with compile time.

You can add additional projects to the runtime classpath of an application or applet class in two ways:

A. Right click the class, select 'Properties' and then the 'Classpath' tab.

B. Right click the class, select 'Run' and then 'Check Class Path'

Either of these methods brings up a dialog where you can edit the Project Path manually (which Projects are included in the runtime classpath), or click the 'Compute Now' to have VAJ find all the referenced projects.
Note that the "Compute Now" function will only find classes that are statically refrenced in the code. If there are classes that are only dynamically referenced, such as through Class.forName(String), then the Projects containing those classes will have to be added manually to the Project Path of the application/applet or the Workspace Classpath.

Also note that classes, such as JDBC drivers, that are not referenced directly by your code during compilation don't have to be imported. You can use the "Extra Directories Path" (under the "Project Path") to point the runtime VM to the JAR(s) containing those classes.

The standard way to handle third party libraries or JAR files and such is to create a new project and import the JAR file. This makes all the JAR classes visible at compile time. Then you simply edit the Project Path (as described above) for any classes that will be using the JAR file.
[FAQ Manager's Comment] You can reference Projects and external classes at runtime for all applications running in VAJ by setting the Workspace Classpath. It is in the Options dialog, under the Resources heading.

If you enter the term 'project path' into the Search utility of the VAJ help system, you'll get a link to the help document entitled 'setting the class path' that gives a few more details.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.