Frequently Asked Questions on Jdt

Can I Use a Java Compiler Other Than the Built-in One (javac for Example) With the Workbench?

No. The JDT provides a number of sophisticated features including fully automatic incremental compilation, code snippet evaluation, code assist, type hierarchies, and hot code replace. These features require special support found in the workbench Java compiler (an integral part of the JDT's incremental project builder), but not available in standard Java compilers.

Where Do Java Packages Come From?

A project contains only files and folders. The notion of a Java package is introduced by a Java project's class path (at the UI, the Package Explorer presents the packages as defined by the classpath). Tip: If the package structure is not what you expect, check out your class path. The Java search infrastructure only finds declarations for and references from Java elements on the class path.

When Do I Use an Internal Versus an External Jar Library File?

An internal resource resides in some project in the workbench and is therefore managed by the workbench; like other resources, these resources can be version managed by the workbench. An external resource is not part of the workbench and can be used only by reference. For example, a JRE is often external and very large, and there is no need to associate it with a VCM system.

When Should I Use Source Folders Within a Java Project?

Each Java project locates its Java source files via one or more source type entries on the project's class path. Use source folders to organize the packages of a large project into useful grouping, or to keep source code separate from other files in the same project. Also, use source folders if you have files (documentation for example) which need not be on the build path.

What Are Source Attachments, How Do I Define One?

Libraries are stored as JAR files containing binary class files (and perhaps other resources). These binary class files provide signature information for packages, classes, methods, and fields. This information is sufficient to compile or run against, but contains far less information that the original source code. In order to make it easier to browse and debug binary libraries, there is a mechanism for associating a corresponding source JAR (or ZIP) file with a binary JAR file.

Why Are All My Resources Duplicated in the Output Folder (bin, for Example)?

If your Java project is using source folders, then in the course of compiling the source files in the project, the Java compiler copies non-Java resources to the output folder as well so that they will be available on the class path of the running program. To avoid certain resources to be copied to the output location you can set a resource filter in the Java compiler preferences: Window > Preferences > Java > Compiler > Building

How Do I Prevent Having My Documentation Files From Being Copied to the Project's Output Folder?

Use source folders and put any resources that you do not want to be copied to the output folder into a separate folder that is not included on the class path. You can also set a resource filter in the Java compiler preferences: Window > Preferences > Java > Compiler > Building to for example *.doc.

How Do I Create a Default Package?

You don't have to. Files in the root folder of a source folder or project are considered to be in the default package. In effect, every source folder has the capability of having a fragment of the default package.

What Is Refactoring?

Refactoring means behavior-preserving program transformations. The JDT supports a number of transformations described in Martin Fowler's book Refactoring: Improving the Design of Existing Code, Addison-Wisely 1999.

When Do I Use Open Declaration (f3)?

To find out the Java element that corresponds to the selected source range with the help of the compiler.

Is the Java Program Information (type Hierarchy, Declarations, References, for Example) Produced by the Java Builder? Is It Still Updated When Auto-build Is Off?

The Java program information is independent from the Java builder. It is automatically updated when performing resource changes or Java operations. In particular, all the functionality offered by the Java tooling (for example, type hierarchies, code assisting, search) will continue to perform accurately when auto-build is off; for example, when doing heavy refactoring which require to turn off the builders, you can still use code assist, which will reflect the latest changes (not yet build). Other than the launching (that is, running and debugging) of programs, the only functionality which requires the Java builder is the evaluation of code snippets.

After Reopening a Workbench, the First Build That Happens After Editing a Java Source File Seems to Take a Long Time. Why Is That?

The Java incremental project builder saves its internal state to a file when the workbench is closed. On the first build after the project is reopened, the Java incremental project builder will restore its internal state. When this file is large, the user experiences an unusually long build delay.

I Can't See a Type Hierarchy for My Class. What Can I Do?

Check that you have your build class path set up properly. Setting up the proper build class path is an important task when doing Java development. Without the correct build path, you will not be able to compile your code. In addition, you will not be able to search or look at the type hierarchies for Java elements.

How Do I Turn off "auto Compile" and Do It Manually When I Want?

Clear the Build automatically checkbox on the Opens the Workspace preference page General > Workspace preference page. When you want to build, press Ctrl+B, or select Project > Build All from the menu bar.

Hint: when you turn "auto compile" off and build manually, you may also want to select the Save automatically before build checkbox on the Opens the Workspace preference page General > Workspace preference page.

When I Select a Method or a Field in the Outline View, Only the Source for That Element Is Shown in the Editor. What Do I Do to See the Source of the Whole File?

There is a toolbar button Show Source of Selected Element Only - all you have to do is un-press it.

Can I Nest Source Folders?

Yes, you can use exclusion filters to create nested source folders.

Can I Have Separate Output Folders for Each Source Folder?

Yes, select the Allow output folders for source folders checkbox in the Java Build Path > Source property page of your Java project.

Can I Have an Output or Source Folder That Is Located Outside of the Workspace?

Yes, you can create a linked folder that points to the desired location and use that folder as the source or output folder in your Java project.

Java development tools (JDT) Java build path page
JDT glossary