Title: Eclipse
1Eclipse
2Excellent Reference
- Eclipse Distilled
- David Carlson, Addison Wesley
- ISBN 0-321-2885-7
- Download Eclipse
- http//www.eclipse.org
- get the Eclipse SDK download, latest release
- be sure to install Java first
- No installer, just unzip it and create a shortcut
for eclipse.exe
3Platform Architecture
Architecture is multi-platform, multi-language,
multi-role, but well just be focusing on its use
as an IDE for Java
Plug-in registry Resources User
Interface Update facility Help
Contributed Plug-Ins etc.
JDT
IDE
Runtime Platform
4Eclipse Plug-Ins
Visual Editor (VE)
UML2
Test and Performance (Hyades)
Graphical Editor Framework
Eclipse Modeling Framework (EMF) structured data
Runtime Platform
5Java IDE
Java Perspective views laid out for a
particular task
Perspective Switcher
Toolbar
Editor
Views
6Using the IDE
New Java Class
New Java Project
New Java Package
Buttons on toolbar will bring up wizards that
walk you through creating a new project, package
or class.
7Create Project Options
Using a fully qualified name would be better,
such as edu.mines.MyProject
Creates src and bin directories will be created
8Create Class Options
warning wouldnt appear if we used a package
youll need to select a src if one isnt
highlighted
click to create main method
9New Class
Default comments for a new class
10New Class (continued
To change comments, select Window gt Preferences,
then in dialog box select Java gt Code Style gt
Code Templates gt New Java Files gt Edit
11New Class (continued)
Notice the revised comments, that match what we
require for our course header comments.
12Update HelloPrinter
13Error in HelloPrinter
Errors identified in red immediately
Listed under Problems after save
14Execution in Eclipse
Simplest way is to select RunAs from toolbar Be
sure the program with main is selected!
Output will appear in the Console view/window.
15Exercise
- Create a project and class in Eclipse
- NOTE Your workspace should be a directory on the
Z\ drive, do not just accept the default. - Test your understanding of print and println
- Experiment with various syntax errors
16Example class BankAccount
17Generates Getters/Setters
Specify which ones to create
Specify location
Specify order of methods (pairs or
all getters/all setters)
Javadoc format by default
18Updated BankAccount
19Generate Constructor Using Fields
20Generate Constructors from Superclass
21BankAccount constructors
Need to add comments
Need to insert default values
call to parent constructor
this is the calling object (implicit
parameter) this can also be used to call one
constructor from within another (can be confusing)
22Chapter 4 Productivity Hint
- Avoid Unstable Layout
- /
- Computes the change due and
- resets the cash register for the
- next customer
- /
- Looks pretty, but tedious to rearrange
- if program changes (and they usually do!)
23Eclipse Aid
- Edit gt Select All (Ctrl-A)
- Source gt Correct Indentation (Ctrl-I)
- All programs that are turned in for grading
should be neatly formatted!
24More on Eclipse Execution
Recently executed classes are listed on a
dropdown when you press the run icon on the
toolbar
The console will contain a message when the class
is terminated, or a red icon to allow you to
terminate if the class is still executing
25More on Eclipse Workspaces Projects
- Workspace is mapped to a file directory
- contains .metadata folder with workspace info,
including .log file - Java projects include .classpath and .project
files - To conserve resources, projects can be closed
(right-click, close project) - Closed projects can be hidden (click on
down-arrow, select filter)
26Eclipse Perspectives
- A perspective is a set of views in a layout that
is well-suited for a particular task. - Java - normal perspective for editing Java files
- Debug include views useful during a debugging
session - Resource shows all files included in project.
NOTE Window gt preferences gt General gt Workspace
gt Refresh automatically can be used if changes
are made to project outside Eclipse - 5 others not covered here.
- Can create you own!