Similar to commands for compiling and running, debugging commands rely on
various information, such as the location of your
sources, the location of the compiled classes and other items on the classpath,
and name of the project's main class.
In , the IDE does not "know"
about any of these things. When you run a command in the IDE (such as Build),
the IDE simply calls a target in your build script and lets the script handle
the command. Therefore, for debugging to work, you also have to have a build script
target for debugging. The IDE provides some custom Ant tasks to work with the debugger
and also can generate a basic debug target, which attempts to fill in important
details based on other targets in your script.
To set up debugging in a free-form project, you need to do the following:
Make sure that your classes are compiled with debugging information included. For
example, you might accomplish this in the compile
target of your build script by including the argument debug="true" in the <javac> task.
If the output of a free-form project is on the classpath of another project,
map the free-form project's source packages to their outputs. This ensures that you can use the
debugger to step into the project's sources when you start a debugging session in a
project that has a dependency on the free-form project. You can do this in the Output
panel of the Project Properties dialog box for the free-form project. You can open the
Project Properties dialog box by right-clicking the project's node in the
Projects window and choosing Properties.
Set the target JDK in your Ant script and specify the source
level in the Project Properties dialog box. When you step into JDK
classes, the IDE searches the platforms registered in the Java Platform Manager
for a Java platform with a matching source level. If no matching Java platform
is found, the IDE opens the source code for the IDE's default platform.
If you have a free-form project on the classpath of another project, you
must declare the free-form project's output files in order to step into classes
from the project. To declare the output files, right-click the free-form project
node and choose Properties. Then click Outputs and specify the output file
for each source folder.