Using Eclipse in CompSci 4
Addendum for Homework 2
Sometimes we need to start from scratch. There's nothing to download.
We don't need an special packages. The problem's from the Text in
Homework 2 present such a situation.
For the purposes of these notes, we are going to deal with a project
named Iliad and a package named homer and a class
named Troy.
You need to substitute the actual names of
project, package, and class(es) you want to work on.
The details apply to the machines
in 229 Social Sciences, the ICC. Other Windows environments are very
similar.
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
- Creating a Class
All executable programs require one or more classes. Repeat this section
as often as needed to create the classes required.
- Select (Click on) Iliad
- File->New->Class
- Name: Troy
- One of your classes requires the method main. If
this is the one, click before "public void main(String[] args)" (If this
is not the one, unclick this box if already checked.)
- 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)
- Finish
- Compiling Source Code
- Always be sure to save any changes before compiling
(Unsaved files show an asterisk in the fields above the main window.)
- Select (Click on)Iliad
- Project->Rebuild Project
- Executing Your Program
If any changes were made, you must Compile (see above) first.
- 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.