Using Eclipse in CompSci 4
For the purposes of these notes, we are going to deal with a project
named Iliad and a package named homer.
You need to substitute the actual names of
project and package you want to work on. The details apply to the machines
in 229 Social Sciences, the ICC. Other Windows environments are very
similar.
Downloading Source Code Onto the Desktop
This copies the necessary files to your desktop. The first time, you
need to download it from the course website. Once you worked on it
and saved it on your acpub directory, you need to download it from there.
- Downloading From Course Website
- Open course website:
http://www.cs.duke.edu/courses/spring04/cps004/
- Click on Code at the upper right
- RIGHT click on homer.jar
- Select Save Target As
- Save to Desktop
- Downloading From the P: Drive (your acpub files)
- double click on My Computer
- double click P: drive
- Change into your cps4 folder
- You should see myhomer.jar
- Drag myhomer.jar onto the Desktop
Using Eclipse
- Starting Eclipse
- Double Click on Classroom Applications on the Desktop
- Double Click on eclipse.exe
- Making a Project
- File->New->Project
- Java->Java Project
- Click on Next
- For Project Name type Iliad
- Click on Finish
- If asked: Switch to Java Perspective? Yes
- Importing Files Into a Project
- File->Import
- Select Zip file
- Click on Next
- From zip file: Click on Browse
- Click on Desktop
- Double click homer.jar (or myhomer.jar )
- Into folder: click on Browse and select Iliad
- Finish
- Executing Source Code (for working program)
- Click on + by Iliad
- Click on + by homer
- Click on Homer.java
- Run->Run as->Java Application
- Program should run: Interact with program as appropriate
- Editing Source Code
- Double click on the appropriate .java file at the left
e.g. homer.java
- (Make the changes in the code)
- (Don't make too many changes before recompiling)
- (It will usually be easier to locate errors after limited
changes>
- Click on the diskette icon to save
(or File->Save)
- Compiling Source Code
- Always be sure to save any changes before compiling (done in the previous step -- unsaved files show up with an asterisk by the tab above
the main code window)
- Click on Homer.java
- Project->Rebuild Project
- Executing the modified code
- Click on Homer.java
- Run->Run as->Java Application
Saving Project
During class projects are saved on the desktop.
Before leaving the lab be sure to save your project to your acpub account.
- Saving Project
- Click on Iliad
- File->Export
- Select Jar file
- Click on Next
- Jar file: click on Browse
- double click on My Computer
- double click P: drive
- Change into cps4 folder
- Use filename myhomer.jar
- Click on Save
- Select (check on) Export java source files and resources
- Click on Finish
ICC Notes
For Eclipse use in the ICC, remember that someone else may have been
using Eclipse since the last time you used it. They might have been
using C++ rather than Java. Eclipse saves and restores its current
environment. Sometimes this gets in the way. If it's clear that
the last use was C++, try Window -> Open Perspective -> Java.