Getting Started with Eclipse
David Matuszek

Downloading and installing

Download Eclipse from

The version I'm using is Eclipse Classic 3.5.1. That's the latest version as I write this; use a newer version if one is available.

Installation is simple, but you must already have the Java SDK installed. Unzip the file and double-click eclipse.exe.

Getting started

The following is slightly modified from

How do I write a simple "Hello World" program?

To write a "Hello World" program follow these steps:

  1. Start Eclipse.
  2. Create a new Java Project:
    1. File → New → Project (or click the "New Java Project" button in the toolbar, and skip the next step).
    2. Select Java Project in the project list. Click Next >.
    3. Enter a project name into the Project name field, for example, Hello World Project.
    4. Click Finish--It will ask you if you want the Java perspective to open. (You do.)
  3. Create a new Java class:
    1. File→ New → Class (or click the Create a Java Class button in the toolbar).
    2. Enter HelloWorld (no space between words) into the Name field.
    3. Click the checkbox indicating that you would like Eclipse to create a public static void main(String[] args) method.
    4. Click Finish.
  4. A Java editor for will open. In the main method, replace the comment with the following line.
         System.out.println("Hello World");
  5. Save using ctrl-s. This automatically compiles
  6. Click the Run button in the toolbar (white triangle in a green disc).
  7. You will be prompted to create a Launch configuration. Select Java Application and click New.
  8. Click Run to run the HelloWorld program. The console will open and display Hello World.

Using the tutorials

The tutorials are online, and I haven't found an easy way to download them so that they can be used offline.

To start a tutorial, first start up Eclipse. Go to the Help menu and choose Help Contents. This should open a browser window with contents in the leftmost pane and "Using Eclipse help system" in the right pane. (I have found that if you try to open a second window this way, it comes up with nothing in the leftmost pane; so use just the one window.)

In the leftmost window, click on Workbench User Guide. Don't click on the icon next to it--that doesn't do anything--but click on the words themselves.

At this point, Getting started looks an acts like a link, but it doesn't do any good to click on it. Instead, click on the + to its left. This opens up and you can click on Basic tutorial, which is a link that opens a page that says "Basic tutorial" and little else. As before, if a link has a + to its left, you need to click on the + to open things up. Doing this again gets you to The Workbench, which is the first page with any useful information on it.

As you step through the sections of a tutorial, you will have to keep track of where you are; the Contents menu on the left does not highlight the current section.

Both Eclipse and the tutorial require a lot of screen space, so you will find yourself frequently switching back and forth between the two. It may help to resize the windows so they are full screen width but not as tall, so you can put one above the other.

You should work through at least these tutorials:
      Workbench User Guide → Getting started → Basic tutorial
      Java Development User Guide → Getting started → Basic tutorial

Running JUnit tests

Before you can write JUnit tests you have to add the junit.jar library to your build class path.

  1. Create a project.
  2. Select the Java file in your project that you want to test.
  3. Choose File → New → JUnit Test Case
  4. Select new JUnit 4 test and click Next>.
  5. Check the methods for which you want tests and click Finish.
  6. If you do not already have JUnit associated with this project, you will get a dialog that offers to Add JUnit 4 library to the build path. Do so.
  7. The created class will have test stubs for all the methods you checked. You can edit this to fill in "real" tests.

Pay special attention to this Eclipse tutorial: Help → Help ContentsJava Development User GuideGetting StartedBasic tutorialWriting and running JUnit tests

Also read: JUnit Test Infected, Note, however, that the examples in this paper use JUnit 3, which uses a slightly different syntax.