Download Eclipse from http://www.eclipse.org/downloads/.
The version I recommend is Eclipse Classic 4.2.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.
The following is slightly modified from http://wiki.eclipse.org/index.php/Eclipse_FAQs:
How do I write a simple "Hello World" program?
To write a "Hello World" program follow these steps:
- Start Eclipse.
- Create a new Java Project:
File → New → Project(or click the "
New Java Project" button in the toolbar, and skip the next step).
Java Projectin the project list. Click
- Enter a project name into the
Project namefield, for example,
Hello World Project.
Finish--It will ask you if you want the Java perspective to open. (You do.)
- Create a new Java class:
File→ New → Class(or click the
Create a Java Classbutton in the toolbar).
HelloWorld(no space between words) into the
- Click the checkbox indicating that you would like Eclipse to create a
public static void main(String args)method.
- A Java editor for
HelloWorld.javawill open. In the main method, replace the comment with the following line.
- Save using ctrl-s. This automatically compiles
- Click the
Runbutton in the toolbar (white triangle in a green disc).
- You will be prompted to create a Launch configuration. Select
Java Applicationand click
Runto run the HelloWorld program. The console will open and display
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
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
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
library to your build class path.
File → New → JUnit Test Case
new JUnit 4 testand click
Add JUnit 4 library to the build path. Do so.
Pay special attention to this Eclipse tutorial:
Also read: JUnit Test Infected, http://junit.sourceforge.net/doc/testinfected/testing.htm. Note, however, that the examples in this paper use JUnit 3, which uses a slightly different syntax.