eclipse IDE

Know Your IDE: Eclipse

Jinal Patel Java, Technology Snapshot 6 Comments

When I made the switch from .NET to Java, I naturally had to switch IDEs. With moving to Java, I chose Eclipse. I was fortunate to have a great group of coworkers that took time out of their schedule to share shortcuts and tips to allow me to utilize Eclipse to the fullest extent.

One of the first shortcuts I found to be very beneficial was Ctrl+Shift+t, which enables you to type a class name and in return it will summarize related or matching files to open. In the sections below I have listed a few other tips for Eclipse that I found useful during the transition and in my experience with Eclipse.

Also, I highly recommend taking a few minutes to read Adi Rosenblum’s Developers Are Lazy (And How To Use That To Your Advantage With Eclipse) for some more great tips on Eclipse.

Code Templates

Code templates enable you to create multiple templates to generate code. Examples of common templates are:

  • Getter field
  • Setter field
  • Constructors of a class
  • Comments for overriding methods
  • Comments for a method

New code templates can be created in an XML file and once created, the file can be imported for use. Default templates can be found by navigating to the Project Menu and then selecting Properties. In the Properties window, expand the Java Code Style and select Code Templates.

Know Your IDE1

Let’s use Getter and Setter as an example and see how templates generate code. A shortcut key (Ctrl+Shift+S) can be used to open the Source Menu or alternatively you can click on Source Menu. Select ‘Generate Getters and Setters…’

Know Your IDE2

A window will pop up with the Getters and Setters options. Select OK to generate the code.

Know Your IDE3

The highlighted section is generated code from the Code Template feature.

Know Your IDE4


Formatter is a great option to achieve a consistent format. When working on a team, Formatter helps avoid whitespace changes and code readability is greatly improved.

To enable and/or change the default format, navigate to Project–> Properties–> Java Code Style–> Formatter.

See Also:  Flow: A Static Type Checker for JavaScript

Know Your IDE5

The highlighted code below is not formatted.

Know Your IDE6

When Formatter is enabled, the format will be automatically corrected based on Active Profile when the changes are saved.

Know Your IDE7

Clean Up

Clean Up is used to remove unnecessary code in a class. Clean Up can be enabled in the Properties files as shown below.

Know Your IDE8

For example, Clean Up can be configured to remove unused imports.

Know Your IDE9

Unused import is deleted by the Clean Up process.

Know Your IDE10

Save Actions

Save Actions can be set up to take place every time a file is saved in the editor. It provides an option for formatting and uses the configuration from Formatter, which was covered in earlier sections. Save Actions also offer the option for code clean up and a variety of rules can be configured in Save Actions. To enable Save Actions, navigate to Properties window.

Know Your IDE11

Find References

When a method or field is selected and you selected Find References, Eclipse will display the list of classes and files that uses the method or the field in the search view. This can be accomplished by using Ctrl+Shift+g. Find Reference is helpful when working on a large project or in multiple member, team setting.

If your task at hand is maintaining code or implementing improvements, it is essential to understand why and where the methods are used before making modification. Furthermore, it is important to verify that the method or the field is not being used elsewhere. If other references are found, make sure any change in method will not break existing code.

Go To Declaration

Go To Declaration helps track code and is particularly helpful during debugging or when trying to understand existing code. You can track what values are being set and what values are being passed to the method.

This is one of the common features across IDEs and the shortcut for Go To Declaration is F3. By selecting the method or the field and utilizing the F3 shortcut, the declaration of the method or the field (variable) will be displayed.

See Also:  Design Pattern: Microservice Authentication + Authorization

Show Annotation and Show History

The versioning repository system in Eclipse provides a great way to synchronize code from multiple developers. Quite often developers work in the same file and on the same piece of code. If a developer neglects to merge code correctly before committing his or her code into the repository, portions of code may suffer errors.

Reviewing the history, via Show History, of the file provides an audit trail to pinpoint the changes and the person who made the change. The key information from the audit trail is the developers name as it allows you to discuss the modifications with him or her. The open dialogue often is a win-win scenario in understanding the requirements, current issues, and preventing further issues.

Show Annotations is different from Show History as Show Annotations provides a detailed line-by-line annotation of the last change. Should you only be interested in reviewing changes of a line of code, Show Annotations is a more efficient way (vs. Show History) to pinpoint a change in the code.


When introduced to new IDE, take some time to explore. This can save you some time in long run and increase your comfort level and productivity. Make sure you get the most benefits out of your IDE and I hope the few tips provided in this blog will help. Please feel free to comment other shortcuts or command that you have found helpful over the time.

— Jinal Patel, [email protected]

Comments 6

  1. Good article! One of my favorite eclipse keyboard tricks is that when you use ctrl-shift-t to find classes, use camel-casing. In projects with lots of classes, for instance, trying to find the UserAccountDaoImpl class may take you 10 keystokes typing the full name until you see your class in the list. Instead, type just the capital letters, UADI! Once you get used to this trick, it can really save you time finding classes with long names.

  2. No article about Eclipse that mentions shortcuts is complete without CTRL + SHIFT + L (or, on Mac, COMMAND + SHIFT + L). That’s the shortcut to show a (L)ist of shortcuts. 🙂

  3. Thank you Keith. I agree with you,that is one of my favorites too. Adi Rosenblum has described how to use CTRL + SHIFT + T in detail in his blog referenced above.

    Thank you Dave for sharing the great tip. That will be a great way to find even more functionality. 🙂

  4. I’d rather Ctrl+Alt+H than Ctrl+Shift+G. Try it out, and tell what you think.
    Other shortcuts I’ve been using a lot is to select related pieces of code text:
    * Alt+Shift+UP : every tap on it selects a wider range of related code, including more and more code sintatically related to the one originally on the cursor (a word + a line + a block + a so on…)
    * Alt+Shift+DOWN : having you selected code using the shortcut explained right above, this one reduces its range, i.e., does the opposite of that.
    * Alt+Shift+LEFT/RIGHT : selects previous/next siblings of code.

    Another one that is sometimes usefull is Ctrl+Shift+X/Y, that upper/lower case a selected text.

  5. Thank you Marcus for more useful tips. Find Call hierarchy Ctrl+Alt+h, does give you more details, I like it.

What Do You Think?