| CIT
591 Getting Started With Eclipse Fall 2004, David Matuszek |
Downloading and installing
The main page is http://www.eclipse.org/ ; start there for everything.
Click on "downloads" in either the main panel or the navigation panel; this will bring you to a page where you can select either the Main Eclipse download site or one of several mirrors. I suggest that you get the "Latest Release." I'm using Release 3.0.1, which is the latest release at the time I'm writing this.
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 http://www.eclipse.org/eclipse/faq/eclipse-faq.html#users_4:
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.
- Select "Java" in the category list.
- Select "Java Project" in the project list. Click "Next".
- Enter a project name into the Project name field, for example, "
Hello World Project".- Click "Finish"--It will ask you if you want the Java perspective to open. (You do.)
- Create a new Java class:
- Click the "Create a Java Class" button in the toolbar. (This is the icon below "Run" and "Window" with a tooltip that says "New Java Class.")
- Enter "
HelloWorld" into the Name field.- Click the checkbox indicating that you would like Eclipse to create a "
public static void main(String[] args)" method.- Click "Finish".
- A Java editor for
HelloWorld.javawill open. In the main method enter the following line.
System.out.println("Hello World");- Save using ctrl-s. This automatically compiles
HelloWorld.java.- Click the "Run" button in the toolbar (looks like a little man running).
- You will be prompted to create a Launch configuration. Select "Java Application" and click "New".
- Click "Run" to run the Hello World 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.
Properties.Java Build Path.Libraries tab.Add External JARs....junit.jar. It should be in a location such as ...Eclipse
3.0.1\plugins\org.junit_3.8.1\junit.jar.junit.jar, click on Open, click
on OK.To create a test class:
File > New > Other...) Java > JUnit in the left pane and TestCase
in the right pane and click Next. OK.To run your test class, select your test class and choose Run as >
JUnit Test from the Run drop-down menu in the
toolbar.
Pay special attention to this Eclipse tutorial: Help ->
Also read: JUnit Test Infected, http://junit.sourceforge.net/doc/testinfected/testing.htm.