Eclipse IDE is an open-source product that was originally created with a substantial code donation by IBM to the Java community, and from that moment Eclipse was a community-driven product. It started as an IDE for developing Java programs, but today it is a development platform used for building thousands of tools and plugins.
Besides being an IDE, Eclipse supports plug-in development, and each developer can add only those plug-ins that you are interested in. For example, there is a plug-in to display UML diagrams, another offers a reporting system, and there are plug-ins for developing applications in C, JavaScript, Apache Flex, and other languages.
DOWNLOADING AND INSTALLING ECLIPSE
There are different versions of Eclipse IDE, and this book uses Eclipse IDE for Java EE Developers. Each version of Eclipse IDE has a name and you could download it from here.
Eclipse manages files in workspace. When the Workbench is launched, the first thing you see is a dialog that allows you to select where the workspace should be located. The workspace is the directory where your work will be stored. For now, just click OK to pick the default location.
After the workspace location is chosen, a single Workbench window is displayed. A Workbench window offers one or more perspectives. A perspective contains editors and views, such as the Project Explorer. Multiple Workbench windows can be opened simultaneously.
To create new project in Eclipse you select File > New menu on the Workbench menu bar. Start by creating a simple project as follows:
-
From the menu bar, select File > New > Project…
-
In the New Project wizard, select General > Project then click Next.
-
In the Project name field, type your name as the name of your new project, for example “JaneQUser”.
-
Leave the box checked to use the default location for your new project. Click Finish when you are done.
If you sneak a peek at the navigation view, you will see that it now contains the simple project we just created.
Next you type code in Editor and press Ctr+F11 to run program.
Popular hotkey in Eclipse
Shortcut | Description |
---|---|
Ctrl+Shift+R |
Search dialog for resources, e.g., text files |
Ctrl+Shift+T |
Search dialog for Java Types |
Ctrl+F8 |
Shortcut for switching perspectives |
Shortcut | Description |
---|---|
Ctrl+E |
Search dialog to select an editor from the currently open editors |
Alt+↠|
Go to previous opened editor. Cursor is placed where it was before you opened the next editor |
Alt+→ |
Similar Alt + ↠but opens the next editor |
Ctrl+Q |
Go to editor and the position in this editor where the last edit was done |
Ctrl+PageUp |
Switch to previous opened editor |
Ctrl+PageDown |
Switch to next opened editor |
Shortcut | Description |
---|---|
Ctrl+F7 |
Shortcut for switching views. Choose the view to switch to with your mouse or cycle through the entries with repeating the keystroke |
Shift+Alt+Q |
Open menu for switch view keybindings |
Shift+Alt+Q+P |
Show package explorer |
Shift+Alt+Q+C |
Show console |
2. Start Java programs
Shortcut | Description |
---|---|
Ctrl+F11 |
Run last launched |
F11 |
Run last launched in debug mode |
Ctrl+Alt+B |
Skip all breakpoints. Let’s you use debug mode for code reloading |
Alt+Shift+X+J |
Run current selected class as Java application |
3. Editing in the Java editor
Shortcut | Description |
---|---|
Shift+Alt+↑ selects enclosing elements. |
Quickfix; result depending on cursor position |
Shortcut | Description |
---|---|
Ctrl+1 |
Quickfix; result depending on cursor position |
Ctrl+Space |
Content assist/ code completion |
Ctrl+T |
Show the inheritance tree of the current Java class or method. |
Ctrl+O |
Show all methods of the current class, press Ctrl + O again to show the inherited methods. |
Ctrl+M |
Maximize active editor or view |
Ctrl+Shift+F |
Format source code |
Ctrl+I |
Correct indentation, e.g., format tabs/whitespaces in code |
Ctrl+F |
Opens the find dialog |
Shift+Enter |
Adds a link break at the end of the line |
Ctrl+Shift+O |
Organize the imports; adds missing import statements and removes unused ones |
Alt+Shift+Z |
Wrap the select block of code into a block, e.g. try/catch. |
Shortcut | Description |
---|---|
Ctrl+↠or Ctrl+→ |
Move one text element in the editor to the left or right |
Ctrl+↑ or Ctrl+↓ |
Scroll up / down a line in the editor |
Ctrl+Shift+P |
Go to the matching bracket |
Shift+Cursor movement |
Select text from the starting position of the cursor |
Alt+Shift ↑ / ↓ |
Select the previous / next syntactical element |
Alt+Shift ↑ / ↓ / ↠/ → |
Extending / reducing the selection of the previous / next syntactical element |
Shortcut | Description |
---|---|
Ctrl+Alt+↓ |
Copy current line below the line in which the cursor is placed |
Ctrl+Alt+↑ |
Copy current line above the line in which the cursor is placed |
Alt+Up |
Move line one line up |
Alt+Down |
Move line one line down |
Shortcut | Description |
---|---|
Ctrl+D |
Deletes line |
Ctrl+Shift+DEL |
Delete until end of line |
Ctrl+DEL |
Delete next element |
Ctrl+BACKSPACE |
Delete previous element |
Shortcut | Description |
---|---|
Shift+Enter |
Adds a blank line below the current line and moves the cursor to the new line. The difference between a regular enter is that the currently line is unchanged, independently of the position of the cursor. |
Ctrl+Shift+Enter |
Same as Shift + Enter but above |
Shortcut | Description |
---|---|
Ctrl+2+L |
Assign statement to new local variable |
Ctrl+2+F |
Assign statement to new field |
4. Coding
Shortcut | Description |
---|---|
Shift+F2 |
Show the Javadoc for the selected type / class / method |
Alt+Shift+N |
Shortcut for the menu to create new objects |
Alt+Shift+Z |
Surround block with try and catch |
5. Refactoring
Shortcut | Description |
---|---|
Alt+Shift+R |
Rename |
Ctrl+2+R |
Rename locally (in file), faster than Alt + Shift + R |
Alt+Shift+T |
Opens the context-sensitive refactoring menu, e.g., displays |
6. Minimum
The following shortcuts are the absolute minimum a developer should be familiar with to work efficient in Eclipse.
Shortcut | Description |
---|---|
Ctrl+S |
Saves current editor |
Ctrl+1 |
Quickfix; shows potential fixes for warnings, errors or shows possible actions |
Ctrl+Space |
Content assist/ code completion |
Ctrl+Q |
Goes to the last edited position |
Ctrl+D |
Deletes current line in the editor |
Ctrl+Shift+O |
Adjusts the imports statements in the current Java source file |
Ctrl+2+L or F |
Assign statement to new local variable or field |
Ctrl+Shift+T |
Open Type Dialog |
Ctrl+O |
Shows quick outline of a class |
Ctrl+F11 |
Run last launched application |
Shift+F10 |
Opens context menu. Keyboard equivalent to Mouse2 |
Ctrl+F10 |
Opens view menu for current view. |