blob: b50bb9c24b3761eb79436ece88458b57d5144b3e [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2015. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>Java Build Path</title>
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
</head>
<body>
<h1>Java Build Path</h1>
<p>The options in this page indicate the build path settings for a Java project. You can reach this page through the project properties (Project &gt; Properties &gt; Java Build Path) from the context menu on a created project or the <a href="ref-menu-file.htm">File
menu</a> of the workbench.</p>
<p>The build class path is a list of paths visible to the compiler when building the project.</p>
<h2>Source tab</h2>
<p>Source folders are top-level folders in the project hierarchy. They are the root of packages containing .java files.
The compiler will translate the contained files to .class files that will be written to the output folder.</p>
<p>Source folders allow to structure the project, for example to separate
test from the application in two source folders. Within a source folder, a more detailed structuring can be achieved by using packages.</p>
<p>Each source folder can define an exclusion filter to specify which
resources inside the folder should not be visible to the compiler.</p>
<p>Resources existing in source folders are copied to the output folder unless the setting in the <a href="preferences/java/compiler/ref-preferences-building.htm">Java &gt; Compiler &gt; Building</a> preference
page specifies that the resource is filtered. The output folder is defined per project except if a source folder specifies its own output folder.</p>
<table border="1" cellspacing="0" cellpadding="5" summary="Source folder options" width="600">
<caption>Source folder options:<br>
</caption>
<tbody>
<tr>
<th>Option</th>
<th>Description</th>
</tr>
<tr>
<td align="left" valign="top" width="20%">Add Folder</td>
<td align="left" valign="top">Creates a new folder to contain source</td>
</tr>
<tr>
<td align="left" valign="top" width="20%">Link Source</td>
<td align="left" valign="top">Creates a new folder that links to an location outside of the workspace</td>
</tr>
<tr>
<td align="left" valign="top">Edit or Toggle</td>
<td align="left" valign="top">Allows to modify the currently selected
source folder or source folder attribute.</td>
</tr>
<tr>
<td>Remove</td>
<td>Removes the selected folders from the class path. This does not
delete the folders nor their contents.</td>
</tr>
<tr>
<td>Allow output folder per source folder</td>
<td>Shows/Hides the 'output folder' attribute of the source folders</td>
</tr>
</tbody>
</table>
<br>
<table border="1" cellspacing="0" cellpadding="5" summary="Source folder attributes" width="600">
<caption>Source folder attributes:<br>
</caption>
<tbody>
<tr>
<th>Attribute</th>
<th>Description</th>
</tr>
<tr>
<td align="left" valign="top" width="20%">Exclusion filter</td>
<td align="left" valign="top">Selects which resources are not visible to the compiler. For details see <a href="../concepts/concept-inclusion-exclusion-patterns.htm">Inclusion and exclusion patterns</a>.</td>
</tr>
<tr>
<td align="left" valign="top">Output folder</td>
<td align="left" valign="top">Only available when <b>Allow output
folder per source folder</b> is checked. Defines a source folder specific output location. If not set the project's default output folder is used.</td>
</tr>
<tr>
<td align="left" valign="top">Native library location</td>
<td align="left" valign="top">Defines the folder that contains the native libraries
(for example 'dll' or 'o' files) required at runtime by the sources in the source folder.
</td>
</tr>
<tr>
<td align="left" valign="top">Ignore optional compile problems</td>
<td align="left" valign="top">When set to 'Yes', all optional problems will not be reported by the compiler.</td>
</tr>
<tr>
<td align="left" valign="top">Contains test sources</td>
<td align="left" valign="top">When set to 'Yes', the sources in the folder are assumed to be test code,
otherwise main code. When compiling main code, only other main code (from the current project or from other projects on the build path) is visible and only dependencies
that are not configured to be visible for test code only. When compiling test code, all code on build path
is visible. When compiling test code with Java 9, the unnamed module is assumed to be readable
by the current module, so test dependencies that should not be mentioned in the <code>module-info.java</code> are accessible if they are put
on the classpath.</td>
</tr>
</tbody>
</table>
<p>At the bottom of this page, the <b>Default output folder</b> field allows you to enter a path to a folder path where the compilation output for this
project will reside. The default output is used for source folders that do not specify an own output folder. Use <b>Browse</b> to select an existing location from the current project.</p>
<h2>Projects tab</h2>
<p>In the <b>Required projects on the build path</b> list, you can add project dependencies by selecting other workbench
projects to add to the build path for this new project.</p>
<p>Adding a required project indirectly adds all its classpath entries marked as 'exported'. Setting a classpath entry as exported is done in the Order and Export tab.</p>
<p>The projects selected here are automatically added to the referenced projects list. The referenced project list is used to determine the build order. A project is always
build after all its referenced projects are built.</p>
<table border="1" cellspacing="0" cellpadding= "5" summary="Project entry options" width="600">
<tbody>
<tr>
<th>Action</th>
<th>Description</th>
</tr>
<tr>
<td align="left" valign="middle" width="20%">Add</td>
<td align="left" valign="top">Add another project in the workspace to the build path of this project.</td>
</tr>
<tr>
<td align="left" valign="middle" width="20%">Edit or Toggle</td>
<td align="left" valign="top">Edit the classpath attribute of a required project.</td>
</tr>
<tr>
<td align="left" valign="middle" width="20%">Remove</td>
<td align="left" valign="top">Removes the selected required projects from the list.</td>
</tr>
</tbody>
</table>
<table border="1" cellspacing="0" cellpadding="5" summary="Project entry attributes"
width="600">
<caption>Project entry attributes:<br>
</caption>
<tbody>
<tr>
<th>Attribute</th>
<th>Description</th>
</tr>
<tr>
<td align="left" valign="top">Native library location</td>
<td align="left" valign="top">Specifies where native library required for the project to operate can be found.</td>
</tr>
<tr>
<td align="left" valign="top">Access rules</td>
<td align="left" valign="top">Specifies access rules for project contained in the library. This allows to hide content of a project.</td>
</tr>
<tr>
<td align="left" valign="top">Visible only for test sources</td>
<td align="left" valign="top">When set to 'Yes', the code reachable via the referenced project is only accessible when sources in sources folder marked to contain test code are compiled.</td>
</tr>
<tr>
<td align="left" valign="top">Without test code</td>
<td align="left" valign="top">When this is set to 'No', test code from the referenced project is not visible when compiling test code in the current project.</td>
</tr>
</tbody>
</table>
<h2 id="libraries">Libraries tab</h2>
<p>On this page, you can add libraries to the build path.</p>
<p>By default, the library list contains an entry representing the Java runtime library. This entry points to the JRE
selected as the default JRE. The default JRE is configured in the <a href="preferences/java/debug/ref-installed_jres.htm">Java &gt; Debug &gt; Installed JREs</a> preferences page.</p>
<table border="1" cellspacing="0" cellpadding= "5" summary="Libraries tab options" width="600">
<caption>
Libraries tab options:<br>
</caption>
<tbody>
<tr>
<th width="20%">Option</th>
<th>Description</th>
</tr>
<tr>
<td align="left" valign="top">Add JARs</td>
<td align="left" valign="top">Allows you to navigate the workbench hierarchy and select JAR files to add to the build path.</td>
</tr>
<tr>
<td align="left" valign="top">Add External JARs</td>
<td align="left" valign="top">Allows you to navigate the file system (outside the workbench) and select JAR files to add to the build path.</td>
</tr>
<tr>
<td align="left" valign="top">Add Variable</td>
<td align="left" valign="top">Allows you to add classpath variables to the build path. Classpath variables are an indirection to JARs with the benefit of avoiding local
file system paths in a classpath. This is needed when projects are shared in a team.<br>
Variables can be created and edited in the <a href="preferences/java/buildpath/ref-preferences-classpath-variables.htm">Java &gt; Build Path &gt; Classpath Variables</a> preference page.</td>
</tr>
<tr>
<td>Add Library</td>
<td>Allows to add a predefined libraries like the JRE System Library. Such libraries can stand for an arbitrary number of entries (visible as children node of the library node)</td>
</tr>
<tr>
<td>Add Class Folder</td>
<td>Allows to navigate the workbench hierarchy and select a class folder for the build path. The selection dialog also allows you to create a new folder.</td>
</tr>
<tr>
<td>Add External Class Folder</td>
<td>Allows to navigate the file system (outside the workbench) and select a class folder for the build path. The selection dialog also allows you to create a new folder.</td>
</tr>
<tr>
<td align="left" valign="top">Edit or Toggle</td>
<td align="left" valign="top">Allows you to modify the currently selected library entry or entry attribute</td>
</tr>
<tr>
<td align="left" valign="top">Remove</td>
<td align="left" valign="top">Removes the selected element from the build path. This does not delete the resource.</td>
</tr>
<tr>
<td align="left" valign="top">Migrate JAR File</td>
<td align="left" valign="top">Migrate a JAR on the build path to a newer version. If the newer version contains refactoring scripts
the refactoring stored in the script will be executed.</td>
</tr>
</tbody>
</table>
<p>&nbsp;Libraries have the following attributes (presented as library entry children nodes):</p>
<table border="1" cellspacing="0" cellpadding="5" summary="Library entry attributes"
width="600">
<caption>Library entry attributes:<br>
</caption>
<tbody>
<tr>
<th>Attribute</th>
<th>Description</th>
</tr>
<tr>
<td align="left" valign="top">Source attachment</td>
<td align="left" valign="top">Specifies where the library's source can be found.</td>
</tr>
<tr>
<td align="left" valign="top" width="20%">Javadoc location</td>
<td align="left" valign="top">Specifies where the library's Javadoc documentation can be found. If specified you can use <b>Shift+F2</b> on an element of this library to open its documentation.</td>
</tr>
<tr>
<td align="left" valign="top" width="20%">External annotations</td>
<td align="left" valign="top">Specifies where <a href="../tasks/task-using_external_null_annotations.htm">external annotations</a> for the library can be found.
If specified these annotations will be considered by JDT for its static null analysis.</td>
</tr>
<tr>
<td align="left" valign="top">Native library location</td>
<td align="left" valign="top">Specifies where native library required for the library to operate can be found.</td>
</tr>
<tr>
<td align="left" valign="top">Access rules</td>
<td align="left" valign="top">Specifies access rules for resources contained in the library. This allows to hide content of a library.</td>
</tr>
<tr>
<td align="left" valign="top">Visible only for test sources</td>
<td align="left" valign="top">When set to 'Yes', the code in the referenced library is only accessible when sources in source folders marked to contain test code are compiled.</td>
</tr>
</tbody>
</table>
<h2>Order and Export tab</h2>
<p>In the <b>Build class path order</b> list, you can click the <b>Up</b> and <b>Down</b> buttons to move the selected path entry up or down in the build path order for this new project.</p>
<p>Checked list entries are marked as exported. Exported entries are visible to projects that require the project. Use the <b>Select
All</b> and <b>Deselect All</b> to change the checked state of all entries. Source folders are always exported,
and can not be deselected.</p>
<p><img src="../images/ngrelc.png" alt="Related concepts" border="0" ></p>
<p>
<a href="../concepts/concept-build-classpath.htm">Build classpath</a><br>
<a href="../concepts/concept-classpath-variables.htm">Classpath variables</a><br>
<a href="../concepts/concept-inclusion-exclusion-patterns.htm">Inclusion and exclusion patterns</a><br>
</p>
<p>
<img src="../images/ngrelr.png" alt="Related reference" border="0" >
</p>
<p>
<a href="../reference/ref-jdt-faq.htm">Frequently asked questions on JDT</a><br>
<a href="../reference/preferences/java/buildpath/ref-preferences-classpath-variables.htm">Classpath variables preferences</a><br>
<a href="../reference/preferences/java/ref-preferences-build-path.htm">Build path preferences</a><br>
<a href="../reference/preferences/java/ref-preferences-compiler.htm">Compiler preferences</a><br>
</p>
</body>
</html>