$29
If you want to do all your lab work on your own PC or Mac, download
Box Sync and Eclipse (steps 12 and 14) before lab on Wednesday so we
don't overload the WiFi. You will do steps 13 and 15 during lab.
If you want to use the lab computer for this lab, please pay attention
to the instructions given for steps 13 and 15 so you will know how to
do them at home later.
PAY ATTENTION to steps 6-9. Read the notes "Object Oriented Programming"
on the CSC220 Lecture Discussion Forum this evening. There will be
questions about it on the quiz Thursday.
1. Accounts
log in
change password:
Applications->System Tools->Terminal
yppasswd
log out and log in again
If you are working on your PC or MAC
log out
start your favorite browser on your PC or MAC
If you are working on the lab computer
start Firefox (Applications->Internet->Firefox)
go into Blackboard for the lecture (miami.edu/blackboard)
discussion board (on the left)
CSC220 Lecture Discussion Board
SUBSCRIBE
go to the lab posting
go to source directory
2. Create a new Java project
start eclipse
right-click on background to start terminal
type eclipse and hit return
OR
Start Eclipse on your PC or Mac.
accept default location for workspace
select workbench (if it gives you a choice)
Create a new Java Project named csc220
Click the little downarrow next to the tiny + on the
upper left
OR
File->New Project->Java->Java Project
Next
project name: csc220
Finish
Don't Create module-info.java (if it asks)
Yes to Java Perspective (if it asks)
If you are working on your own PC or MAC
shut down Eclipse
do steps 13 and 15 now.
restart Eclipse
3. Create a new package for this lab
expand csc220 (on the left)
right click on src
new -> package
name it prog01 (NOT Prog01 NOT prog 01 NO CAPITALS OR SPACES)
Finish
4. Create java files in this package
visit the source directory (on the discussion board)
visit Main.java
save into workspace/csc220/src/prog01
do the same for Computer.java and Laptop.java
click on prog01 in Eclipse and press f5
or right-click and select REFRESH
5. Fix compiler errors and run
open prog01
double-click on Main.java
comment out offending lines
press white triangle inside green circle to run
Go to line with runtime error by double clicking on it
something like (Main.java:21)
comment out line with run time error and try again
6. Debugging
set a breakpoint on the first line "Set a breakpoint here..."
(right click to the left of line and select Toggle Breakpoint)
run the debugger (buggy icon next to white triangle)
let it switch you to debug perspective
single step through the program
use step-into (two symbols to the right of red square near top)
if you get a blank screen too many times, use step-return
if you are not calling methods in the package, use step-over
notice how you can see the value of variables
notice how you can see where you called from
try changing the value of a variable, like procSpeed in Computer
to access object variables, expand "this"
try setting breakpoints in methods
7. Use the Visual Debugger
It's already installed in the lab.
To install on your PC or Mac:
Open Eclipse and go to Help->Install New Software...
Click Add.. and use location
http://web.cs.miami.edu/home/jgmaster/DebugPlugin/
Hit Add.
Uncheck "Group Items by Category" on this form
Check CSC220 Debugging Visualizer
Click "next" and "accept" until it starts to install
To Use:
Put a breakpoint in whatever file you're going to debug
Go to Window->Show View->Other...
Expand the Debug category and select "CSC220 Debugging Visualizer"
The view should appear in the panel near the console view,
You can move this around and even move it out by just dragging the tab.
Start debugging the program with the bug button
When the program breaks on a breakpoint,
the visualizer should show the current state
of the data structure and all other local variables.
Single step (over or into) and the visualization should update.
Try looking at the Variables view and try to see the correspondences
from the textual layout of the data to the visual layout
Double click a node with a highlighted border to expand it
Drag the nodes in between single stepping:
they should remain in place during the next step.
Right click and click save in the context menu
to save an image of the figure
8. Object Oriented Programming
notice that c2 is an instance of a Laptop
even though the variable is of type Computer
Even if we call your laptop a computer, it's still a laptop.
For example, I say: ``Please install Eclipse on your computer.''
That might refer to your laptop or your desktop.
notice that when you print out c2,
it calls the Laptop toString method
you can set a breakpoint in that toString method
9. Overriding a method
uncomment the computePower method in Laptop.java
fix the first compiler error by using getRamSize()
fix the second error by changing processorSpeed
from private to protected in Computer.java
**notice that c2.computePower() now calls this method**
DIAGNOSTIC EXERCISE
10. Put Lamb.java in place and run it. You need to right click on it
and run it as an application. Ask for help if you can't get it
running. It will run but print incorrect output:
Mary had a little lamb
Mary had a little lamb
Mary had a little lamb
Mary had a little lamb
Mary had a little lamb
Mary had a little lamb
Final sentence should be:
Doctor Mary only had eaten a very little lamb chop
11. Implement the insert method. Your final output should be:
Mary had a little lamb
Mary had a very little lamb
Mary only had a very little lamb
Doctor Mary only had a very little lamb
Doctor Mary only had a very little lamb chop
Doctor Mary only had eaten a very little lamb chop
Final sentence should be:
Doctor Mary only had eaten a very little lamb chop
This is a diagnostic exercise. Feel free to ask the assistants
for help using the debugger, but do not ask them or your fellow
classmates for hints about the correct logic or why your program
isn't working.
Show your working program to an assistant and tell them your login
id (????220) if you can get it working before the end of lab period.
HOMEWORK ON YOUR PC or MAC
12. Log into box.miami.edu. This is a free web storage provided to UM
students.
Click on your name or initials on the upper and select apps.
Select Windows or Mac. Download and install Box Sync.
Run Box Sync and set up your CaneLink credentials.
This process should have created a folder named Box Sync on your computer.
13. ON YOUR COMPUTER using File Explorer or Finder
(NOT ON THE WEB in box.miami.edu)
create a folder inside your Box Sync folder with the same name as
the login you are given in lab on Wednesday. It is four of your
initials followed by 220, like vjmi220 for Victor Milenkovic.
NOW go back to the main page of box.miami.edu and verify that the
folder has (magically) appeared there.
Right-click on your folder on box.miami.edu.
Share --> Invite Collaborators.
Invite vjm@cs.miami.edu using the default setting
(making me an Editor).
14. Install Eclipse: go to eclipse.org/downloads and click Download 64-bit.
Windows users may also have to install the JDK. Try the x64 version first.
Run Eclipse and take note of where it puts your "workspace".
Go to the workbench and create a new Java project named csc220.
See step 2 above.
Shut down Eclipse.
15. Go to the eclipse-workspace/csc220 folder in the file explorer or
finder and delete src.
Replace it with a link from the folder you created in Box Sync:
On a PC
Click start, type "command prompt" in the run window, and hit return.
Adapt the following command to your circumstances:
mklink /d c:\Users\Victor\workspace\csc220\src c:\Users\Victor\"Box Sync"\vjmi220
On a Mac
spotlight (cmnd-space or click the magnifying glass).
Search for "terminal" and hit return.
Adapt the following command to your circumstances:
ln -s /Users/vjm/"Box Sync"/vjmi220 /Users/vjm/eclipse-workspace/csc220/src
16. Do steps 4-9 above on your PC or Mac. When you are done, go to
box.miami.edu. In your folder you should see Computer.java etc
plus an images folder containing images of your debugging with the
Visual Debugger. If you reply to the prog01 posting with a
request for help.