5 Tips for Customizing Eclipse

The Eclipse IDE not only is one of the most popular IDEs. It’s also a very complex tool with countless features and commands. Knowing most of these features is crucial for developers. The following articles contains five tips for customizing and tweaking the Eclipse IDE.

Customize your Perspectives and Views

The Eclipse workbench consists of different perspectives which can be switched via toggle buttons at the right side of the toolbar. Each perspective consists of different views like the editor view, the Package Explorer or the Outline view. Inspect the predefined perspectives to decide which suits your needs. I prefer to use the most basic perspectives: Java, Debug, Team Synchronizing and SVN Repository. After deciding which perspectives to use you really should customize views contained in each perspective. You can easily change the layout of a perspective by dragging the views around. Click on a views tab to drag it to another position. Eclipse not only enables you to arrange views as visible tabs. You can also arrange them as so called fast views. Per default fast views are located at the left side of the statusbar at the bottom of the screen. Drag any view to this little toolbar to use it as a fast view. When clicking on a fast views icon, the view opens as an overlay panel and will automatically be hidden if you click anywhere outside this panel. Sidenote: you can use the same behaviour on minimized views. After altering your perspectives layout feel free to customize the perspectives toolbar, menubar and commands. Right-Click on the perspectives toolbar and choose Customize Perspective.

Use Working Sets to group projects by context

Eclipse uses the concept of workspaces to group multiple Java projects into one folder. Each workspace uses its own preferences which are saved in a hidden folder called .metadata located in the workspace folder. Most likely Java applications consist of multiple Java projects. Eclipse enalbes you to easily structure your workspace by creating several groups of projects called Working Sets. In the Package Explorer view click on the little arrow at the top right corner, then choose Top Level Elements -> Working Sets. Next step is to partition the Java projects into your own working sets. Again, click on the little arrow and choose Configure Working Sets. A dialog opens to create and manage working sets. Eclipse enables you to add whatever you want into a working set (e.g. whole Java projects, classpath folders, packages, classes, libraries, plugins, …). So if you’re just working with a few packages, create a working set containing these packages. This makes navigating via Package or Project Explorer much more convenient. Use Right-Click -> Go Into to restrict the view to only show the content of a working set (this also works on packages).

Limit Open Type results to not showing particular classes

One of my most used commands to find particular java files is the open type command (CTRL + SHIFT + T). The dialog enables you to find any type of java file from your workspace even those included in third party libraries. This can be problematic when some of your java projects depend on the same libraries. If the same library exists multiple times in your workspace then open type shows the same class multiple times. Fortunately it’s possible to limit the results shown by the Open Type dialog. First open the dialog, then click on the little arrow located at the top right corner. Now you can either use type filters to limit the results or you can restrict the results to a predefined working set. To filter multiple types in the dialog choose Select Working Set…, then create a new Java working set via New… button. Eclipse enables you to add whatever you want into a working set. Feel free to add whole Java projects, particular classpath folders or different libraries from you workspace. But pay attention to not adding multiple versions of the same library so the Open Type dialog won’t show different versions of the same class files any more.

Use different background colors for separate workspaces

Sometimes it’s useful to setup multiple workspaces, e.g. if you’re working on different branches of the same project. Often I find myself working on multiple workspaces at the same time, which can be quite confusing. To differenciate one workspace from another I just use different editor background colors for each workspace. With this approach I can see at first glance which workspace is currently open. You can change the editors background color in Preferences -> General -> Editors -> Text Editors. Choose Background color from the list and set the value to whatever you want.

Use Static Import Favorites for accessing static methods/fields faster

The static imports feature was first introduced with Java SE 5. From my experience this feature is rarely used because of poor IDE support. For using static imports efficiently in Eclipse you can add some class (e.g. Assert for writing unittests) to the static import favorites. From now on Eclipse automatically adds static methods and fields of these favorite classes into the code assist popup. Setup your favorites here: Preferences -> Java -> Editor -> Content Assist -> Favorites

Read More