Eclipse: Tips & Tricks
This page shows you how to perform a number of small, but useful tasks in Eclipse - particulary those whose commands are a bit buried in menus.
-
In the code editor, select the identifier (class, method name, or variable) to find.
-
Choose the Search menu > Occurrences in File > Identifier
-
The Search output window displays a list of all matching occurrences in the current file:
-
Double-click an item to go directly to that occurrence.
- Use the gold arrow buttons in the Search window's toolbar to cycle through each occurrence, or hit the grey X buttons to clear the search.
-
-
In the code editor, select the identifer (class, method, variable name) or text you wish to find.
-
Go to the Search menu > Search... (or hit the Ctrl + H keys).
-
The Search box appears. Hit the File Search tab:
-
If your search text does not already appear in the Containing Text box, enter the text. (Check ON Whole word for an exact word or phrase match.)
-
Choose the Scope of your search
-
For all projects, choose Workspace
-
For just the current project, choose Selected Projects
-
-
Hit the Search button.
-
The Search output window displays a list of all matching occurrences in the current project or workspace, along with their project and package locations:
-
Double-click an item to go directly to that occurrence.
-
Use the gold arrow buttons in the Search window's toolbar to cycle through each occurrence, or hit the grey X buttons to clear the search.
-
-
Go to the Search menu > Search... (or hit the Ctrl + H keys).
-
The Search box appears. Hit the Java Search tab:
-
In the Search String box, type the name of the search item.
-
Choose your options for the search:
-
Search For: choose Method, Type for a class, or Field for an instance variable.
-
Limit To: choose References for all references in code, or All Occurrences to include class definitions.
-
Scope: choose Workspace for all projects, or Selected Projects for just the current project.
-
-
Hit the Search button.
-
The Search output window displays a list of all matching occurrences in the current project or workspace, along with their code paths (project > file > class > method):
-
Double-click an item to go directly to that occurrence.
-
Use the gold arrow buttons in the Search window's toolbar to cycle through each occurrence, or hit the grey X buttons to clear the search.
-
-
In the Package Explorer window, right-click on the project and choose Show In > System Explorer:
-
File Explorer or Finder opens with your project folder selected.
× Tip: On Windows, you can ZIP your project folder for submission by right-clicking it and choosing Send to > Compressed (zipped) folder.
The safest way to rename a package or class in your project is to change its name through the Package Explorer window, not in your code.
-
In the Package Explorer window, right-click on the class or package and choose Refactor > Rename...:
-
The Rename window appears. Change the name of your class/package, then hit the Finish button:
-
If a window appears reporting problems, hit the Finish button.
Unless you gave the class or package an invalid name, Eclipse safely changes its name in your code, as well as its file name in the Package Explorer.
-
Right-click on the method or variable you want to rename and choose Refactor > Rename...:
-
Eclipse highlights the name for you. Type the new name of the method/variable, then hit the Enter key:
Unless you give the method or variable an invalid name, Eclipse safely changes all occurrences of it in your code.
If your Eclipse workspace appears "messed up" - windows missing, out of place, or collapsed - the easiest way to get things back in order is to reset the workspace's perspective.