25
 Copyright © Intertech, Inc. 2010  A 10 day Guide to Becoming an Eclipse Guru I love the game of golf. It is a game that requires you coordinate hundreds of muscles in your body in a precise fashion in order to shoot well. Unfortunate ly, I think novice golfers are overwhelmed by all the mechanics. As they are just trying to hit the ball, someone has put dozens of thoughts in their mind. “Keep your head down.” “Grip the club this way.” “Rotate your shoulder that wa y.” “Keep thi s arm straight.” “Bend thi s arm here.” Yikes! Its no wonder some give up the game before ever enjoying it. A golf instructor once told me, if you want to work on your swing, pick one, maybe two things at a time to concentrate on and that is it.  Anymore and it gets in the way. Once you have mastered those few changes, pick a couple more and keep improving.  Just hit it! The other day, I was working with someone o n a piece of software in Eclipse. They were new to the tool. I found myself back-seat progra mming. “Hit contr ol shift F.” “Now go here and hit Alt up arrow.” Etc. Etc. After a few minutes, the person on the keyboard turned to me and said  “Can you tell me what we just did?” They knew Java; they just didnt have all the shortcuts and tips I had memorized over the years. They were overwhelmed by the Eclipse “mechanics”. Consequently , they were lost and frustr ated. I should have been more interested in “just hitting the ball.” In this case, that means j ust getting the co de written and ru nning. After fo cusing o n the code for a while, I slowly began introducing the person to a few helpful shortcuts. By the end of our small session, the person had about a half dozen shortcuts that were making them more productive without overwhelming them. More importantly, we got our code working. Eclipse is an immense tool filed with all sorts of productivity enhance ments, baked-in best practices and patterns, guardrails, and tricks to help the most sophisticated software engineers on the planet write and test good code - quickly. However, not all of us are up to the rank of Top Gun Software Jockey. Sometimes the tool can be a little overwhelming. Therefore, for those just learning Eclipse, or even those that use it, but would like to start to learn a few new tricks in order to be more productive, I have prepared a 10-day training guide to make you a better software en gineer in Eclips e. I dont want you to try to swing like Tige r Woods on day one (youd forget it all by day 2). So , unlike other Eclipse tips and trick guides you may have seen, I want you to concentrate on only a few new features each day. Keep them in your

10 Day Personal Eclipse Training Guide

Embed Size (px)

Citation preview

Page 1: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 1/24

 

Copyright © Intertech, Inc. 2010 

 A 10 day Guide to Becoming an Eclipse Guru

I love the game of golf. It is a game that requires you coordinate hundreds of muscles in your

body in a precise fashion in order to shoot well. Unfortunately, I think novice golfers are

overwhelmed by all the mechanics. As they are just trying to hit the ball, someone has putdozens of thoughts in their mind. “Keep your head down.” “Grip the club this way.” “Rotate

your shoulder that way.” “Keep this arm straight.” “Bend this arm here.” Yikes! It‟s no wonder

some give up the game before ever enjoying it. A golf instructor once told me, if you want to

work on your swing, pick one, maybe two things at a time to concentrate on and that is it.

 Anymore and it gets in the way. Once you have mastered those few changes, pick a couple

more and keep improving.

 Just hit it!

The other day, I was working with someone on a piece of software in Eclipse. They were new to

the tool. I found myself back-seat programming. “Hit control shift F.” “Now go here and hit Alt

up arrow.” Etc. Etc. After a few minutes, the person on the keyboard turned to me and said – 

“Can you tell me what we just did?” They knew Java; they just didn‟t have all the shortcuts andtips I had memorized over the years. They were overwhelmed by the Eclipse “mechanics”.

Consequently , they were lost and frustrated. I should have been more interested in “just hitting

the ball.” In this case, that means just getting the code written and running. After focusing on

the code for a while, I slowly began introducing the person to a few helpful shortcuts. By the end

of our small session, the person had about a half dozen shortcuts that were making them more

productive without overwhelming them. More importantly, we got our code working.

Eclipse is an immense tool filed with all sorts of productivity enhancements, baked-in best

practices and patterns, guardrails, and tricks to help the most sophisticated software engineers on

the planet write and test good code - quickly. However, not all of us are up to the rank of TopGun Software Jockey. Sometimes the tool can be a little overwhelming.

Therefore, for those just learning Eclipse, or even those that use it, but would like to start to learn

a few new tricks in order to be more productive, I have prepared a 10-day training guide to

make you a better software engineer in Eclipse. I don‟t want you to try to swing like Tiger Woods

on day one (you‟d forget it all by day 2). So, unlike other Eclipse tips and trick guides you may 

have seen, I want you to concentrate on only a few new features each day. Keep them in your

Page 2: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 2/24

 

Copyright © Intertech, Inc. 2010 

memory while you are coding and try to use them as often as you can on that day. Put them on

a sticky note and hang it near your monitor. I hope that by day number 10 these tips and tricks

will be baked into your programming sub-conscious. Your coworkers will see you as the Eclipse

guru of the team.

The 10-day training program provides two (2) shortcuts and one (1) little know Eclipse feature (I

call them “power features”) you can focus on each day. I am assuming that you already know

the basics of Eclipse and Java. I also assume you already know some of the very basic shortcuts

and features of the tool (like Control-Shift-S to save a file). Oh and one more assumption - I

assume you are using the Eclipse Helios release or better. If not, get it here. Many of the tips

and features may work in older versions of Eclipse, but why bother. Just like in golf, you are

going to do better with the most modern equipment.

 Without further ado, on to day 1 of training.

Let‟s start day 1 of your training with a pair of shortcut keys to help you find a class,

method, etc. to help you write code without having to memorize an API.

CTRL + Space: code assist/code completion. In a code editor, this shortcut opens a list of 

available code completions. For example, you have an instance of a class, but you cannot

remember what method or field can be called on that instance. Code assist will tell you. In my 

example below, I have an instance reference (model) to a Model object. Code assist provides me

list of methods I can call on the instance. I hate memorizing APIs and code assist is my weapon

of choice in the fight against memorizing the API.

Page 3: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 3/24

 

Copyright © Intertech, Inc. 2010 

However, code assist also works just as well to help you with Java syntax. In this example, I want

a for loop in my code. I use code assist to help provide me with a list of for loop templates.

CTRL + H: search. This shortcut, used from anywhere in Eclipse, opens the Search dialog. You

can use this dialog (shown below) to search for just about anything in the Eclipse workbench.

You can look for a file, a piece of text, a piece of Java code (example: class, method, field), or

just about anything. The Search dialog is a powerful tool and offers many options. You could

write an entire tutorial on this tool alone.

Page 4: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 4/24

 

Copyright © Intertech, Inc. 2010 

 As a simple example, you have a class CustomerSSN and you need to change (refactor) the code

in this class. So, your first question is, “Where is CustomerSSN used?” Using the Search dialog,

you can check for all references to the CustomerSSN within the source files of your Workspace.

Once you press the Search button, a separate Search view opens providing you all the places

where CustomerSSN was found.

Power Feature: Code Assist Using Camel Case. Eclipse has put some “smarts” into the code

assistant to help you select and write code faster. Specifically, the code assistant is aware of 

camel casing. If code abides by camel casing naming conventions, code assist uses camel case

patterns to find code faster. In the example below, I need to create a new

BadCustomerIDException. By providing the upper case characters of the class name, code assist

knows to find a type matching the camel case characters when called on.

Page 5: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 5/24

 

Copyright © Intertech, Inc. 2010 

Similarly, if I need to call on a setter method, I simply ask code assist for help finding a setter

method using „s‟ and the first uppercase character of the field. 

On this second day, let‟s give you some easy to use and understand shortcuts that operate

on lines of code in a Java editor.

CTRL + D: delete a line of code. To delete a line of code, place the cursor on the line of code

you want removed in the editor and hit the shortcut. No fuss, no “are you sure?” dialogs. Note,

if code is folded (like imports or methods all summarized under one line of code), only the first

line of the folded code is removed. If a chunk of code is selected and you hit the shortcut, all the

selected code is deleted.

ALT + Up Arrow and ALT-Down Arrow: Move the line of code up (or down). This pair of 

shortcuts has opposite effect. To move a line of code up one line, put your cursor on the line of 

code you want moved in the editor and hit the ALT + Up Arrow keys simultaneously. Use ALT +

Down Arrow to move the line of code down one line. If a chunk of code is selected, the entire

selected chunk of code is moved up/down using the shortcut.

Power Feature: Save Actions. When you save a file, of course you expect Eclipse to save the file

as well as compile the code creating the .class file. However, you can have Eclipse do a lot of 

other work for you when you save a Java file. Actions you want to have Eclipse perform at the

time you save the file are called Saved Actions. For example, I like my code tidy, so I like to have

Eclipse format my code when I save a file. By default, Eclipse does not perform any actions when

you save. To specify Save Actions, click on the Window option on the Eclipse menu bar. From

the menu presented, select Preferences (see below).

Page 6: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 6/24

 

Copyright © Intertech, Inc. 2010 

The Preferences window displays. Locate Java > Editor > Save Actions in the options listed on

the left-hand side of the window (as shown below). The Save Actions options allow to pick from

some commonly used save actions (like formatting code or organizing imports) as well as

configure your own custom actions. Save time by letting Eclipse do more work for you using Save

 Actions.

Expanding on Day 2‟s shortcuts, today‟s shortcuts also operate on lines of code in an

editor.

CTRL + ALT + Up Arrow/Down Arrow: Duplicates a line of code. This pair of shortcuts copy or

more precisely duplicate, the line of code that the cursor is on above (up arrow) or below (down

arrow) the current line. When a chunk of code is selected, this same shortcut copies the selected

code above or below the existing code.

Page 7: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 7/24

 

Copyright © Intertech, Inc. 2010 

CTRL + /: Comment or uncomment a line of code. This shortcut is a toggling shortcut. The

shortcut will comment an uncommented line of code and will uncomment a commented line of 

code. When text is selected in multiple lines of code, it will comment (or uncomment) all the lines

of code that are selected (or partially selected).

Power Feature: Comment Templates. There are many cases where Eclipse writes code for you.

 When it does, it can also comment for you too! Comment templates allow you to configure what

Eclipse should comment, and how it comments code produced for you. To setup a comment

template, select Window > Preferences from the Eclipse menu bar.

In the Preferences window that appears, select Java > Code Style > Code Templates from the

options in on the left selection bar as shown below. Then, select the type of generated code andpush the Edit… button to enter your comment pattern. Make sure the “ Automatically add

comments for new methods and types” check box is checked (it is unchecked by default). 

Page 8: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 8/24

 

Copyright © Intertech, Inc. 2010 

 When you push the edit button, you get to enter your comment pattern. The pattern can take

advantage of system variables for dynamic output.

On Day 4, it‟s time for some help refactoring. 

ALT + SHIFT + R: Refactor/Rename. Use this shortcut to rename a class, interface, field,

variable, etc. In the example below, I have used the shortcut on a selected instance variable.

Eclipse tells me to simply type in the new name of the instance variable and then hit enter.

Page 9: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 9/24

 

Copyright © Intertech, Inc. 2010 

 When you refactor the name, Eclipse also searches your code and changes all references to the

item (in this case the instance variable).

ALT + SHIFT + V: Move code. When refactoring, you often need to move code around. You

may need to move a class from one package to another. You may need to move an instance or

class variable from one class to another. This shortcut allows you to pick your code and then pickits refactored destination. This shortcut behaves slightly differently depending on what code you

have selected. For example, if you put your cursor on a type in an Explorer (Project, Package,

etc.) view and use the shortcut, Eclipse shows you a Move dialog to transfer the selected type to

another package.

 As an alternate example, an instance variable is selected below and the shortcut is used to move

the instance variable declaring text to another type.

Page 10: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 10/24

 

Copyright © Intertech, Inc. 2010 

Power Feature: Generate code. Eclipse can be used to generate all sorts of mundane code such

as getter and setter methods, constructors, toString( ) method, etc. To have Eclipse generate thistype of code, select open a particular type in a Java editor and the select Source from the Eclipse

menu bar as shown below.

In the Source menu, you‟ll see several “Generate…” menu options. Many of these tasks are socommon, you might want to set up a custom shortcut key (covered later in this training) to make

generating code even faster. You can also get to the same options by right clicking on a code

editor view and selecting Source > Generate… from the resulting menu (shown below).  

Page 11: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 11/24

 

Copyright © Intertech, Inc. 2010 

Some of these code generators can be real time savers. One of my favorite and often used

generators is for creating getter/setter methods on domain classes. Simply declare a new class,

add your instance variables and then let code generation take care of the rest. As you can see

from the Generate Getters and Setters window below, Eclipse offers all sorts of options to code

generation. Most of the time, defaults rule and code gets generated much faster than you can

write it.

Page 12: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 12/24

 

Copyright © Intertech, Inc. 2010 

It‟s the halfway point in your guru training. How about some shortcuts that allow you to

move between editors more quickly?

ALT + Left/Right Arrow: Navigate to the Last/Previous Editor. When you are writing code, it is

common to be working in several classes all at once – that is to open and work in several codeeditors. Eclipse keeps a list or history of your file visits and edits as you move among classes.

You can use this pair of shortcuts to move around your last code visits. In the example below, I

opened four classes. The shortcuts can be used to move me among the editors.

You can also use CTRL + F6 to move between editors. This shortcut (an extra shortcut for Day 5),

allows you to pick from the editors.

CTRL + W/CTRL + SHIFT + W: Close the editor (current/all). Use this shortcut when you need

to close the code editor in which you are currently working. Use CTRL + SHIFT + W to close all

open editors. If any file displayed in an editor has been modified, Eclipse will prompt you to save

the file. CTRL + F4 and CTRL + SHIFT + F4 do the same job.

Power Feature: Refactor. Eclipse was not a tool built by one person. It is a tool built by the

community. As such, it facilitates your use of skills, talents and industry standards of that entire

community. Nowhere is this more evident than in options provided under the Refactor option of 

the Eclipse menu bar.

Page 13: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 13/24

 

Copyright © Intertech, Inc. 2010 

In this menu, you‟ll find all sorts of options for performing code changes. That‟s probably 

obvious. What is not so evident is that many of the code changes offered per this menu help you

implement many good design patterns, conventions, and good general coding practices. Take

for example the Extract Superclass…, Extract Interface…, or Extract Class… options. If you have

a class or interface that is starting to get too big and/or share traits with other classes these

options allow you to quickly extract and establish new types.

Page 14: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 14/24

 

Copyright © Intertech, Inc. 2010 

In fact, I would submit a good improvement of both your Eclipse skills as well as your coding

skills is to become familiar with each option in the menu. Know what the option offers and

how/when to use it. Chances are good that becoming familiar with each of the Refactoring

menu options will cause you to get familiar with many design ideas and patterns that every coder

should know.

For Day 6, here are a few more shortcuts to help navigate your way around code.

CTRL + Q: Last edit. Yesterday, you learned to navigate between editors. This shortcut takes

you to the last edit – regardless of whether the editor is still open or not. This can come in handy 

when you realize your last edit was a mistake or when you forgot to copy something from your

last edit to the next edit.

CTRL + M: Maximize/unmaximize the editor. No matter what size monitor you have, there is

only so much screen real estate and it is usually not enough to see an entire class or any view in

Eclipse (for example, the Console view is often too small to really see all the contents). Use this

shortcut to maximize any editor or view to occupy the entire Eclipse window. By the way, you can

also accomplish the same task by double clicking on the view/editor‟s tab with your mouse. This

is another toggling shortcut. With a maximized view, hit the shortcut again and it will take the

view back down to its “regular” size. In the example below, the shortcut is used twice – first to

maximize the Customer editor and then to return the editor to its normal size.

Power Feature: Code folding. Have you ever heard the expression: “you can‟t see the forest

through all the trees”? Sometimes it gets difficult to see what code is doing because of all the text

you are looking at. Code folding can help eliminate a few of the “trees” in coding. Code folding

allows you to “fold” or hide many lines of code under one line of code. For example, when you

are trying to understand a piece of code, you probably don‟t need to look at the import

statements to appreciate what‟s going on. Below, the import statements are shown as they exist

in a class and as they are shown with code folding turned on.

Page 15: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 15/24

 

Copyright © Intertech, Inc. 2010 

In particular, when code folding is enabled, you might notice the little icon next to the single

import statement.

If you click on this symbol, you can see the other “folded” import statements. When “unfolded”

the icon next to the code changes so that it can be folded back.

So folding code does not really affect the code at all, it just helps hide some of the less important

lines so you can concentrate on the more important lines. You can customize what code is

folded. Use the Eclipse menu bar and select Windows > Preferences to open the Preferences

window. In the Preferences, locate and click on Java > Editor > Folding in the left side options.

This opens configuration options that allow you to fold various types of code or to enable/disable

code folding in general (see below).

Have you ever had difficulty trying to find the beginning or end of a block of code (code

designated with squiggly brackets)? If so, today‟s shortcuts can help. 

Page 16: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 16/24

 

Copyright © Intertech, Inc. 2010 

CTRL + SHIFT + P: Find matching bracket. Place your cursor after a {, [, (, or < character and

use this shortcut to find the matching }, ], ), or > character. Using the shortcut moves your cursor

to the matching close character. Of course, this “bracket matching” shortcut works in the

opposite direction as well – that is put your cursor after a } and it will find the opening {. This

can be helpful in complex Java code, but it also works in other types of code as well. In

particular, this can be handy in matching angle brackets in XML code.

CTRL + SHFT + F: Format code. Not to say that the previous shortcut is unnecessary, but

sometimes proper formatting is all it takes to identify code blocks. White space is ignored in Java

(as it is in many programming languages). Conventions have been established to help make

Java code easier to read and understand. Of course, these formatting conventions can make it

harder to write the code. If you are like me, as you are writing code, you are thinking faster than

you can type. So the code gets into the editor, but it‟s a bit sloppy to look at. When this

happens, use this shortcut to let Eclipse apply conventions to format your code. In the example

below, the code entered is correct/compiled Java code but it is not formatted to help the reader.

The same code is shown next to it after using the formatting shortcut.

Power Feature: Format preferences. Now that you know how to have Eclipse format code, is

there a way to effect the formatting? Formatting is actually more convention than formal

standard. A couple of conventions are usually preferred among Java teams, but your team may feel strongly about one and/or wish to modify the formatting used by the team. If you want to

tweak the formatter Eclipse uses or if you want to define an entire new format convention, head

back to the Preferences window in Eclipse (select Window > Preferences from the Eclipse menu

bar). In the Preferences window, find the Java > Code Style > Formatter item in the list options

on the left. The Edit… button on the window allows you to edit the formatting used by Eclipse.

Page 17: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 17/24

 

Copyright © Intertech, Inc. 2010 

The formatting “Profile” window that opens when you hit the Edit… button offers an incredibly 

detailed set of options for building format constraints on your code. Everything from how much

whitespace is displayed between code elements to how comments are displayed can becustomized.

Page 18: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 18/24

 

Copyright © Intertech, Inc. 2010 

 When applications get big, finding things can get tough. Sure, you can use the CTRL-H

search facility, but there are a couple of other options that are dedicated to finding code elements

(fields, methods, types).

CTRL + O: Type outline. When you have a Java file open, you can use this shortcut to open a

popup displaying a view of the static and instance members, methods, constructors, etc. defined

in the type (see example pictured below). You can also use this outline to pick and go to one of 

the definitions in the editor. When a Java type like a class becomes large, this can be very 

helpful to get you to parts of the class in a hurry. By the way, CTRL + F3 opens the same outline

popup.

Page 19: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 19/24

 

Copyright © Intertech, Inc. 2010 

F3: Open declaration. Ever open a piece off code and see a type, method, field, etc. used in the

code and you need to modify it? Perhaps you just need to see what it does or how it is defined.

Use this shortcut to quickly take you to the file containing a declaration you have selected. In the

example below, if I hit F3 with the cursor on ContactList, Eclipse opens the Java file containing the

ContactList class in an editor.

 As an extra shortcut that is closely related to the type outline shortcut, you might want to explore

CTRL + SHIFT + T. This shortcut opens an Open Type dialog window that lets you find and open

a Java type in an editor.

Power Feature: Hide deprecated. The Java language has grown and changed over the years.

There are deprecated APIs that, while not removed from the language for backward compatibility 

reasons, should not be used in new code. Likewise, you might have application code that has

grown and changed over the years. Perhaps your code also has deprecated features.

Unfortunately, just marking a class, method, or piece of code deprecated does not guarantee that

someone won‟t use it. To help (but not prohibit) others from using deprecated code no matter

where it comes from, consider hiding deprecated code from all code assist situations. Use the

Preferences window to ask Eclipse to hide deprecated code when requesting options with content

assistance. Select Window > Preferences from the Eclipse menu bar, to bring up the Preferences

window. In the window, select Java > Editor > Content Assist from the list of options on the left.

Page 20: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 20/24

 

Copyright © Intertech, Inc. 2010 

Then, check the Hide deprecated references option in the Content Assist options displayed (this

option is unchecked by default).

Now, when content assist is requested, deprecated types, fields, methods, etc. are no longer

available (notice that deprecated constructors are no longer available in the example below).

You are almost done with your training. Here are a couple of miscellaneous shortcuts to

round out your training.

ALT + ENTER: Properties. When developing an application, you often need to get to the

Properties window. The Properties window allows you to configure a project, server or even

application component beyond the code. You can go through the menu options to get to the

Page 21: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 21/24

 

Copyright © Intertech, Inc. 2010 

properties, or you can simply use this shortcut to quickly display the Properties window for a

selected object. The example below shows the Properties window opened for the selected Eclipse

project.

CTRL + SHIFT + O: Organize Imports. You know that in order to use types not defined in the

current package or in the java.lang you need to import the package of those types or fully qualify 

the types. If you are like me (again, remember I don‟t like to memorize the API), you might

remember the class name, but you rarely remember the full package name that it belongs in.

This shortcut comes to the rescue of the package-name impaired. When editing a type in an

editor, use this shortcut to have Eclipse automatically put the necessary import statements at the

top of your file. When more than one type has the same name is detected, Eclipse asks for your

advice on which import statement should be included (as shown below when it detected the need

for an import based on the Date type).

Page 22: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 22/24

 

Copyright © Intertech, Inc. 2010 

Power Feature: Customizing short cuts. With your training nearly complete, you may be thinking

this shortcut idea is great. You might even think, “It would be great if _____ had a shortcut.”

 Well, any Eclipse command can have a shortcut. You simply need to define your own shortcut for

the command. You may also wish to change shortcuts. Perhaps you are an emacs or vi expert.

You wish Eclipse used many of the shortcuts you have memorized over the years in these popular

editors. Well, you can change the shortcuts to match those editors. To add or change a shortcut,open the Preferences window (select Window > Preferences from the Eclipse menu bar). In the

Preferences window, select General > Keys. Under the key bindings, you can pick a command

and change the shortcut or bind a new shortcut to the command. You might also notice the

Scheme drop down. An alternate Emacs key binding is offered, but you can find other key 

bindings on the Internet.

You have made it to the last day. If you are not an Eclipse Guru by now, keep working

through these last shortcuts and power feature. They can help you make it the rest of the way.

CTRL + SHIFT + L: List of shortcut keys. I hope that this training has engrained several helpful

shortcuts into your coding subconscious. Unfortunately, there are hundreds of shortcuts. When

you need help, this shortcut can give you a scrollable list of other shortcut (or if you prefer – key 

bindings).

Page 23: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 23/24

 

Copyright © Intertech, Inc. 2010 

CTRL + 3: Find a command. If the list provided by the shortcut above (CTRL + SHIFT + L) is not

enough, you can locate a command using the search capability provided by this shortcut. CTRL

+ 3 opens a popup search facility to find a command by name. In the example below, I am

looking for a command to open the file search dialog.

Power Feature: Eclipse tips and tricks. Don‟t stop learning now! You can find a ton of help out

on the Internet, but you can also get more help directly from Eclipse. Under the Help option on

the Eclipse menu bar, you‟ll find a Tips and Tricks… item. 

Page 24: 10 Day Personal Eclipse Training Guide

8/3/2019 10 Day Personal Eclipse Training Guide

http://slidepdf.com/reader/full/10-day-personal-eclipse-training-guide 24/24

 

In fact, selecting this menu option opens a dialog box that allows you to go to many collections of 

Eclipse tips and tricks. In the Help windows that open from these selections, you will find many 

more shortcuts, features and helpful guides.

Congratulations Eclipse Guru! You have graduate from the 10-day guide. More importantly, I

hope you find yourself more productive in your coding endeavors. In your work, if you have

another shortcut or Eclipse feature you think others need to be aware of, make sure you leave a

comment in the blog. I welcome the feedback.

Beyond Eclipse, if you are looking for training in a Java subject, I hope you will consider an

Intertech class. You can find our curriculum listed located on the web at:

http://www.intertech.com/Courses/CourseCategory.aspx.