When creating Java applications you typically set up a single main project
which contains both the project main class and any required projects.
Whenever you create separate
for each of a project's source roots, you have to set up the
classpath dependencies between the main project and the required projects. A
required project is a project that has been added to another project's classpath.
For that have a main class specified, the IDE automatically copies
any JAR files on the project's classpath to the dist/lib folder
when you build the project. 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
Whenever you clean and build a project, the IDE also cleans and builds
its required projects. The required project's attached Javadoc and source
code are also made available to the project that you are building.
If you want to add a to the classpath of a standard project, you have to declare all
of the JAR files that are produced when the free-form project is built. Right-click the free-form project's
node in the Projects window and choose Properties. Then specify those JAR
files in the Output page of the dialog box.
To configure project dependencies:
In the Projects window, expand the node of the project to which you want to add a dependent project.
Right-click the Libraries node and choose Add Project.
Select the directory containing the project whose JAR files you want to
add to the classpath. When you select the project directory, the project name and project JAR
files are displayed in the dialog's right pane.
The file chooser depicts IDE project directories using
icons.
Click Add Project JAR Files.
The IDE adds the dependent project to the primary project's classpath and display a node for it within the Projects window's Library node.