Java Development Tips & Tricks

Use Drag & Drop to create a method

To create a method that has the same signature as an existing method, you can use Drag & Drop or Copy / Paste.

Use Quick Fix to create a new method

Start with the method invocation and use Quick Fix (Ctrl+1) to create the method.

Use Quick Fix to handle exceptions

Unhandled exceptions are detected while typing and marked with a red line in the editor.
Press Ctrl+1 to surround the call with a try catch block. If you want to include more statements in the try block, select the statements and press Ctrl+1
If the call is already surrounded with a try block, Quick Fix will suggest adding the catch block to the existing block.
If you don't want to handle the exception, let Quick Fix add a new thrown exception to the enclosing method declaration

Smart Javadoc

Enter '/**' and press Enter. This automatically adds a Javadoc comment stub containing the standard @param, @return and @exception tags.

If you want to open the Javadoc documentation for a type, method or field just press Shift+F2.
If the javadoc for the type , method or field is not configured, you have to first specify the documentation locations to the elements parent library.
Right click on the Parent Library (Project) select properties-> Javadoc Location

Focus the type hierarchy by just pressing F4

To get an understanding of which types in a hierarchy override a method use the 'Show Members in Hierarchy' feature.
Select the method to look at and press F4
With the method selected in the Hierarchy view, press the 'Lock View and Show Members in Hierarchy' tool bar button
The hierarchy view now shows only types that implement or define the 'locked' method. You can for example see that 'isEmpty()' is defined in 'List' and implemented in 'ArrayList' and 'Vector' but not in 'AbstractList'

Compress package names

If your package names are very long you can configure that viewers show a compressed name. Configuration of the compression pattern is done in Preferences > Java > Appearance

Define prefixes or suffixes for fields, parameters and local variables

In addition to configuring the prefix or suffix for fields, you can 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 content assist, quick fix, and refactoring whenever a variable name needs to be computed.

Word wrap in Variables view

The details area of the debugger's Variables and Expressions views supports word wrap, available from the view drop-down menu.

Command line details

You can always see the exact command line used to launch a program in run or debug mode by selecting Properties from the context menu of a process or debug target, even if the launch has terminated.

Similar Topics
WSAD Shortcuts
Workbench Tips and Tricks
New Features in JDE
Java Development Tips & Tricks

Use of this website constitutes acceptance of the Terms and Conditions