Notice: Undefined index: rate in /home/content/p3pnexwpnas11_data03/84/3795084/html/wp-content/themes/publisher/includes/functions.php on line 5532
Eclipse is one of the most popular IDEs with countless extensions and plugins for developers working in Java ecosystem. Eclipse provides a solid environment for developing, debugging, and running applications. In one of our previous journal entries, we talked about some of the most popular Java IDEs available in the market. However, in this journal entry, we will be looking at Eclipse IDE and some of the best productivity tips for Eclipse Java IDE.
With the latest release of the Eclipse IDE, known as Oxygen, there are many improvements that have happened. Some of them are:
- Support of Java 9 out of the box.
- Better Java 8 support.
- Shows the last returned value while debugging a Java program.
- Support for JUnit 5.
To find more about the latest improvements you can have a look here.
Productivity Tips for Eclipse Java IDE
#Switch Editor Window using Ctrl+Tab
If you are fond of using Ctrl+Tab on your browser window, then you can do yourself the favor of using the same feature to move between your Java Source Files. You can do so by following these simple steps:
- Goto to Window -> Preferences -> Keys
- Search for “Next Editor” and “Previous Editor”
- Override their bindings to Ctrl+Tab and Ctrl+Shift+Tab
#Use the “Incremental” option in the Search Dialog
Check the Incremental checkbox in the search dialog box when you hit Ctrl+F to search for a text in the source file. The Incremental helps in making the occurrence of the searched text appear as you type it. This will help you to avoid typing too many characters and then hitting return to find what you are looking for.
#Navigation and Search Shortcuts
List of some of the shortcuts that will help you understand your code.
- F3 or Ctrl+Left Click: Jumps to the declaration of the element.
- Ctrl+T: Help you view the type hierarchy and implementation methods.
- Ctrl+Alt+H: Help you view the call hierarchy of the selected element.
- Ctrl+Shift+G: Help you search the entire workspace for all references of the selected element.
- Ctrl+Shift+T: Help you search for a Class, Interface, or Enum.
- Ctrl+Shift+R: Help you search for a resource.
#File Search Feature
This feature is very useful if you are searching for a text in all the files in your workspace. You can also search using some filters like file type, the scope of the search, i.e., search only on the particular project.
#Use Ctrl+Space and Ctrl+1 for Content Assist and Quick Fixes
The keybinding Ctrl+Space is a useful key combination as it allows for auto-completion of the text. It can also be used for overriding methods and generate getters/setters, constructors.
The keybinding Ctrl+1 can become very handy in quick fixes such as:
- Assigning Constructor parameters to new or existing class fields.
- Assigning a statement to a local variable.
- Renaming a field, variable or class, etc.
#Use Alt+Shift+S Code Generation Actions
The keybinding Alt+Shift+S can be used to quickly add some common code:
- Overriding HashCode() and equals()
- Overriding toString()
- Generating Getters/Setters and Constructors.
#Shortcuts to Run, Debug, and Inspect Code
This list should always be handy while you are debugging your code:
- Ctrl+F11: Run the last application launched.
- F11: Debug the last application launched.
- F5: Step into the code.
- F6: Step over the code, i.e., move to the next line.
- F7: Return to Caller
- F8: Resume the code until the next breakpoint.
- Ctrl+Shift+I: Evaluate the selected expression.
#Disable Build Automatically
If your workspace is large with a lot of dependent projects, then the Build Automatically default behavior will be time-consuming because it triggers an internal build upon saving. To uncheck the same simply open the Project Menu from the toolbar and uncheck the Build Automatically option. This change will make you in control of when to manually build your project. You can use the keybinding Ctrl+B or go to the Project -> Build All to build your project.
#Your Friend – Ctrl+3
The most important keybinding in Eclipse is the Ctrl+3. This keybinding is used for Quick Access, an entry point to virtually anything you can do in IDE. It can be used to open a view, create a new project, but we normally do it for code refactoring.
#Source of the dependent Libraries
If you are working on a large Maven based project and there are a lot of dependencies, in such a scenario it is always advisable to download the sources of the dependent libraries. The download will help you understand the method signature and it will make the Javadoc comments available in your IDE. To download the sources you can follow any of the below methods:
Goto Window -> Preferences -> Maven when selected automatically will fetch the source artifacts of the dependencies.
You can download the source manually by right-clicking the dependency in the Maven dependencies tree and selecting Maven -> Download Sources
#Group Related Projects in Working Sets
If you are working on multiple projects then there might come a situation that you have to manage multiple workspaces to organize your projects. There is a solution to this problem, you can try to organize your related projects in Working Sets. By keeping your projects in working sets you don’t have to jump between workspace or open multiple Eclipse window with different workspaces. This keeps your projects organized and most importantly accessible from within the same view.