By default, the runtime classpath of each
contains the project's compiled classes and everything in the
project's compilation classpath. For information on viewing the compilation
classpath, see Managing
the Classpath.
If your project uses special libraries dynamically at runtime through an indirect
interface or reflection (like JDBC drivers or JAXP implementations), you have
to add these libraries to the runtime classpath.
For that have a main class is specified, the IDE automatically copies any JAR
files on the project's classpath to the dist/lib folder.
The IDE also adds each of the JAR files
to the Class-Path element in the application JAR's manifest.mf
file. This simplifies running the application outside the IDE. For more
information, see Preparing
a JAR for Deployment Outside the IDE
You also have to adjust your
runtime classpath if the runtime dependencies between your projects do not
match the compilation dependencies between the projects. For example, imagine
that project A compiles against project B, and project B compiles against project
C, but project A does not compile against project C. This means that project
A only has project B on its runtime classpath. If project A requires both project
B and project C during execution, you have to add project C to project A's runtime
classpath.
To set the runtime classpath:
Right-click the project node in the Projects window and choose Project Properties.
In the Project Properties dialog box, select the Libraries node in the
Categories pane.
Select the Run tab in the dialog's right pane.
Add the necessary elements to the project's runtime classpath by clicking
the appropriate button. You can add any of the following:
Project. The
build output, source files, and Javadoc files of another IDE project.
Adding a project to the classpath makes it dependent on the present project.
Whenever you clean or build the project, all of its dependent projects
are also cleaned or built.
Library. A collection
of binary files, source files, and Javadoc files.
JAR file. A JAR file or folder somewhere on your system.
Folder
(Optional) Click the Move Up and Move Down buttons to alter to the
classpath priority.
In , your Ant script handles the classpath for all of your source
folders. The classpath settings for free-form projects only tell the IDE
what classes to make available for code completion and refactoring. For
more information, see Declaring
the Classpath in Free-Form Projects.