When you build a project, the IDE calls the corresponding target in the project's
Ant build script. The IDE compiles the source files and generates the packaged
build output, such as a JAR file or WAR file. You can build a project
and all of its required projects, or build any
project individually.
You do not need to build the project or compile individual classes to run the
project in the IDE. By default, the IDE automatically compiles classes when you
save them. These incrementally compiled files are stored in a cache in your
user directory and are copied to your project's build folder
when you run or debug your project. This incremental compilation can save you
a lot of time when you are editing and testing your project.
However, you need to build the project to generate distributable files
for the project, such as JAR files.
By default, the Build Project command is not enabled since most of that command's
functions are handled by the incremental compilation. However, you can use the
Clean and Build command to create a fresh build. When you clean
and build a project, all previous build outputs are deleted and new versions
of the build outputs are created.
To build a project and its required projects:
Select the project that you want to build in the Projects window.
Choose Run > Clean and Build Project (Shift+F11).
Alternatively, right-click the project's node in the Projects window and choose Clean and Build.
The IDE displays the Ant output and any compilation errors in the Output window.
You can double-click any error to go to the location in the source code where the error occurred.
If you are building a project often you can set a project as the main project by right-clicking a project in the
Projects window and choosing Set as Main Project or by choosing Run > Set Main Project
from the main menu and selecting the project in the sub-menu.
After you set a project as the main project the keyboard shortcuts for
Run (F6), Build (F11) and Clean and Build (Shift+F11) will apply to the main project
regardless of which project is selected in the Projects window.
Keyboard shortcuts for Debug and Profile will also apply to the main project.
To stop building a project:
Choose Run > Stop Build/Run from the main menu.
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
To turn off incremental compilation for a project:
Right-click the project's node and choose Properties.
In the Project Properties dialog box, select the Compiling node and
clear the Compile On Save checkbox.