Tips and Tricks

[This section should make interesting bathroom reading for an end user of Eclipse 2.1. It should give them bits of advice on how to use Eclipse effectively. It should stay away for things that a user would naturally discover while using Eclipse, and instead focus on high-value things that they might not have noticed. It also differs in tone from the "New for 2.1" section in that it deals with anything in 2.1, not just the new stuff. Each item should stand by itself (as they would have to if we had a "Tip of the Day" facility).]

[Coming soon...this section will be primed with material lifted from the M2 through M5 "New and Noteworthy" bulletins.]


Code assist Hit CTRL+SPACE in the Java editor to ask for suggestions for how to finish what you're typing.

Reminders in your Java code When you tag a comment in Java source code with "TODO" the Java compiler automatically creates a corresponding task as a visible reminder. Opening the task navigates you back to your that place in the code. Use the Java / Task Tags preference page to configure any other special tags (like "FIXME") that you'd like to be reminded of.

Prominent status indication Both the Default Text editor and the Java editor now display a prominent large spot in the upper right corner to indicate that the file contains errors or warnings.

Building Java project cycles Java projects that depend on each other can usually be compiled successfully in a single build action. However, in order for cycles to be allowed, you must to lower the severity associated with circular dependencies on the Java / Compiler preference page.

Move instance method refactoring You can select an instance method and select Move from the context menu. It allows you to move the method to the declared class of one of the method's parameters, or to the declared class of a field. This creates a new method and converts the old method into a delegate (passing it 'this' if necessary).

Pull Up refactoring

Pull Up refactoring is more powerful now. Additional functionality includes:

  • Members can be pulled up more than 1 level in the class hierarchy.
  • Instead of pulling methods up you can choose to declare them abstract in the destination class. This will add method stubs to all non-abstract subclasses of the destination class if required.
  • By pressing Add Required you can compute the set of all members that are required to be pulled up together with those already selected.

Push Down refactoring

Select a set of non-static methods and fields declared in a class and choose Refactor > Push Down. For each of the methods and fields you can then choose if you want to either:

  • push it down to subclasses, or
  • (in the case of methods) push it down to subclasses and declare an abstract method in the class that currently declares the method, or
  • leave it as is

Non-shared project filter for Package Explorer and Project views There is a new filter for excluding non-shared projects from Package Explorer and Projects view:

Find in file The Search menu group contains a new command to search for all occurrences of types, fields, methods and local variables inside the compilation unit or class file declared the element. Consistent with other search commands, markers are generated and presented as annotations in the editor. Entries in the Search Results view have different icons for read and write access. For example, the search results for "fName" in "TestCase.java" look like:.

Special end character for patterns in Open and Go To dialogs The various Open and Go To dialogs now support the end character '<'. So if you want to see all types in the Open Type dialog that end with "Test" you have to enter the pattern "*Test<". If '<' is not present in the pattern, a '*' is appended to the pattern. So entering "*Test" in the Open Type dialog shows all types containing "Test" somewhere in the type name.
Multiple method restore You can now restore multiple Java elements from the local history in one operation by selecting Restore From Local History from the context menu. In the left pane of the dialog, check the elements you want to restore and for each checked element select a history entry from the right hand side.

Type hierarchy view supports grouping by defining type The type hierarchy method view lets you sort the selected type's methods by their defining type. For example, for AbstractList you can see that it contains method that were defined in Object, Collection, and List:

Improved prefix and suffix configuration for variables In addition to configuring the prefix or suffix for fields, you can now also specify the prefix or suffix for static fields, parameters, and local variables. These settings on the Java / Code Generation preference page are used in code assist, quick fix, and refactoring whenever a variable name needs to be computed.

Customizable code generation The Java / Code Generation preference page now allows you to customize generated code and comments in a similar way that normal templates are defined. These code templates are used whenever code is generated. (The comments replace the existing 'filecomment' and 'typecomment' templates used for code generation.)

Add Delegate Methods wizard Similar to the Create Getter/Setter wizard, you can now easily generate delegate methods (methods that delegate to a method provided by an instance variable).  The action is available on all types with fields.
Sort members There is now a Sort Members action on the context menu of Java compilation units and top level types that rearranges the members of a compilation unit according to the category order defined in the Java / Appearance / Member Sort Order preference page.
More Quick Fixes and Quick Assists
  • Create missing constructors.
  • Remove unused private methods/fields or types.
  • Fix ambiguous imports.
  • Suggestion to organize imports.
  • Create method in outer type (for methods in anonymous classes).
  • Remove if/while/for/do statement or block and correctly indent the content.
  • Quick assist offers surround-with templates when called on a multi-line selection.

Note: For existing workspaces, you may need to reset the templates back to their default values.

Compiler flags unused private members The Java compiler can now warn of private method, field, or type declarations which aren't used. The setting is on the Java / Compiler preference page.

JUnit Select a JUnit test method in a view and choose Run > Run As > JUnit test. This creates a launch configuration to run the selected test.
Controlling your console Output displayed in the console can be locked to a specific process via a drop-down menu in the Console view toolbar. There's also a new scroll lock button that stops the console from automatically scrolling as new output is appended.

New ways to create watch items The Java debugger can now create watch items from the Java editor by selecting an expression and using the Watch action (available in the context menu, and in the Run menu). As well, a watch item can be created by selecting a variable and using the Watch action.
Improved conditional breakpoints A traditional conditional breakpoint is triggered by a boolean expression evaluating to "true". It is now possible to declare conditional breakpoints that are triggered whenever the value of an expression changes.

Step filters Step filters are more convenient to use now that a Step With Filters action has been added to the debug toolbar and menu. As well, actions have been added to the debug context menu to streamline the creation of step filters for the type or package associated with the selected stack frame.
Editing launch configurations Holding down the Control key and making a selection from the Run or Debug drop-down menu opens the associated launch configuration for editing. The launch configuration can also be opened from the context menu associated with any item in the Debug view.
Word wrap in
Variables view
The details area of the debugger's Variables and Expressions views now supports word wrap, available from the view drop-down menu.

Hierarchical vs. flat layout of packages An option on the Java Packages (and Package Explorer) view allows you to change the way packages are displayed. Hierarchical displays packages in a tree, with subpackages below packages; Flat displays them as the traditional way, as a flat list where all packages and subpackages as siblings.
Logical packages The Java Packages view (Java Browsing perspective) coalesces packages of the same name across source folders within a project. This presents a view of a logical package.
In-place outlines Press Ctrl+F3 (Navigate  > Open Structure) in the Java editor to pop up an in-place outline of the element at the current cursor position. Or press Ctrl+O (Edit > Open Structure) to pop up an in-place outline of the current source file.

Inplace Outline

Hover information in editor overview The Java editor's right hand side overview ruler now shows hover information for problem annotations.

Overview hover

Quick assist Position the cursor in an identifier and press Ctrl+1 (Edit > Quick Fix) in the Java editor to invoke the quick fix mechanism even when there are no errors.
  • Linked rename: Available on all identifiers. Switches into the editor linked mode editing (like templates), where changing the identifier changes all occurrences of that name within the source file.
  • Move catch block to throws declaration: Available on the catch statement.
  • Assign expression statements to a local variable or field: Available on all expression statements. e.g.: 
  •    vector.iterator();
    will be transformed to
       Iterator iterator= vector.iterator();
    Quick assist will guess a variable name for you.
Stack trace hyperlinks Java stack traces in the console now appear with hyperlinks. When you place the mouse over a line in a stack trace, the pointer changes to the hand and the stack trace is underlined. Pressing the mouse button opens the associated Java source file and positions the cursor at the corresponding line.

Refactoring can update non-Java files When renaming a Java type or package (or when moving a type to a different package), the fully qualified name of the element can now be updated in non-Java files as well.