Java Build Path
If you've done any Java programming before, you're familiar with the Java classpath—a list of directories and JAR files containing Java classes that make up the program. Usually this is controlled by an environment variable (CLASSPATH) or a command-line option (-cp).
In Eclipse, classpath details are a little more complicated. The first thing to realize is that Eclipse doesn't use the CLASSPATH environment variable. It understands and controls the location of all classes itself. Additionally, Eclipse makes a distinction between runtime and build (compile) time. In Eclipse terminology, classpath refers only to the runtime class list, while build path refers to the compile-time list. These two paths may be different, but, by default, they will both be set to the list you specify in the build path.
To see the build path, right-click on your project and select Properties → Java Build Path. A dialog will appear, with the tabs described in Table 6.
Table 6-1. Java Build Path tabs
|
Tab name |
Description |
|---|---|
|
Source |
Tell the Java compiler where your source code is located. Each source directory is the root of a package tree. You can also control where generated output files (such as .class files) go. |
|
Projects |
Make the current project depend on other projects. Classes in the other projects will be recognized at build time and runtime. The other projects do not have to be built into a JAR file before referring to them in Eclipse; this cuts down on development time. |
|
Libraries |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access