Eclipse basics for Java development

Just a basic into to Eclipse, aimed at people who are new to Java. Covers creating a new project, debugging, common shortcuts/navigation, git.


Workspace contains your settings, ex your keyboard shortcut preferences, list of your open projects. You can have multiple workspaces.


You can switch between Workspaces via File ->Switch Workspaces


A project is essentially an application, or a library to an application. Projects can be opened or closed. Content of closed projects don’t appear in searches.

Hello world Project

To run some basic java code:

  • File -> New -> Java project
  • Give the project some name ->  finish.
  • Right click on src -> New -> Class
  • Give your Class some name, check “Public static void main(String [] args)”
  • Add “Hello World” print line:
    System.out.println(“Hello world”);
  • Right click on “” -> run as -> Java Application
  • Output printed in Console:
  • Next time you can run the file via run button:Selection_092.png
  • Or via “Ctrl+F11”


Set a breakpoint by double clicking on the line numbers in the margin, then click on the bug icon or right click and “Debug as” -> “Java appliaction”

For more info on debugging, head over to Vogella:

Switching perspectives

Eclipse has the notion of Perspectives. One is for Java development, one for debugging, (others could be C++ development, or task planning etc..). It’s basically a customisation of features and layout.

When you finish debugging, you can switch back to the java perspective:

Common keyboard shortcuts

  • Ctrl+/    – comment code “//”
  • Ctrl+shift+/    – comment code ‘/* … */’
  • Ctrl+F11   – Run last run configuration
  • Ctrl+Shift+L  Keyboard reminder cue sheet. (Type to search)
  • Ctrl+Shift+L, then Ctrl+Shift+L again, open keyboard preferences.
  • Ctrl+O – Java quick method Outline:
    Note: Regex and case search works. Ex “*Key” will find “getBackgroundColorKey()”, so will  “gBFCK”.
  • Ctrl+Shift+r – search for resource (navigate between your classes).
  • Ctrl+Shift+f – automatically format the selected code. (Or all code if no block selected).

For more on shortcuts, head over to Vogella:

Source code navigation

Right click on a method/variable to bring up a context menu, from there select:

Open Declaration (F3)

This is one of the most used functions. It’s a universal “jump to where the method/variable/class/constant is defined”.


Open Call hierarchy

See where variable or method is called.

Tip: For variables, you can narrow down the Field Access so that it only shows where a field is read/written.


Quick outline (Ctrl+O)

The quick outline is a quick way to find a function in your class. It has regex support and case search. E.g “*size” will find any method with ‘size’ in it and “cSI” will find ‘computeSizeInPixels’.
Tip: Press Ctrl+O again and you will be shown methods that get inherited from parent classes.


Navigate to super/implementation (Ctrl+click)

Sometimes you may want to see which sub-classes overrides a method. You can hover over a method and press ctrl+click, then on “Open Implementation”.


You will be presented with a list of sub-implementations.


You can similarly navigate to parent classes.

Code completion

Predict variable names, method names,

Start typing something, press: “Ctrl+space”


It can complete by case also, ex if you type “mOF” and press Ctrl+Space, it will expand to “myOtherFunction()”.


Typing “System.out.println();” is tedious. Instead you can type “syso” and then press ‘ctrl+space’. Eclipse can fill in the template code.Selection_084.png
You can find more on templates in Eclipse Preferences.

Git integration

99% of my git workflow happens inside Eclipse.

You will want to open three useful views:

Window -> Show view -> others

  • Team -> History
  • git -> Git Repositories
  • git -> Git Staging

You can manage git repositories in the “Git Repositories” view:


You can add changed files in the “Git Staging View” via drag and drop, and fill in the commit message. You can view your changes by double clicking on the files:


In the “History” view, you can create new branches, cherry pick commits, checkout older versions. Compare current files to previous versions etc..



More on Eclipse

If you want to know more about the Eclipse interface, feel free to head over to Vogella’s in-depth Eclipse tutorial:

Also free free to leave comments with questions.

5 thoughts on “Eclipse basics for Java development

  1. Hi blogger, i must say you have high quality content here.
    Your blog should go viral. You need initial traffic boost only.
    How to get it? Search for; Mertiso’s tips go viral


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s