SlideShare a Scribd company logo
1 of 19
Page 8 of 8
3.Tutorial: Get Started with Eclipse in the Computer
Lab[footnoteRef:1] [1: This tutorial is modified from
Eclipse Tutorial – Getting Started by Dr. John Dean
(http://captain.park.edu/jdean/tutorials/eclipseDnldTutorial.doc
) and
How To Install Eclipse and Get Started with Java Programming
from
https://www3.ntu.edu.sg/home/ehchua/programming/howto/Ecli
pseJava_HowTo.html (retrieved on 8/8/2015)]
(Last updated: 8/16/2015)
In this tutorial you will practice using Eclipse to build Java
programs in computer labs (such as SC113) on campus. We will
practice:
A. Get familiar with the Eclipse IDE
B. Set up the coding style preference (such as two-space indent
and soft tab) used in this course
C. Build and run the famous Hello World! Project
D. Create a project by copying from an existing project
E. Terminate a running program
* * *
Eclipse is an Integrated Development Environment (IDE) that
allows you to enter, compile, and run programs. The programs
can be written in one of many different languages, such of Java,
C/C++, and PHP. Computer labs on campus already has Eclipse
ready for Java development.
The screenshot below shows the default layout of Eclipse. Take
a look now and refer back to this screenshot as to where things
are while you work through this tutorial.
1. Menu
2. Toolbar
3. Package Explorer: display all your projects and files. Yours
will be empty at this point.
4. Editor
5. Outline view: displays data and method members of the
currently selected Java class
6. Console panel
If you accidentally closed or moved one of the panels above,
you can always restore this default layout by:
· First choose “Window” menu => “Open Perspective” =>
“Other…” and select “Java (default)” in the “Open Perspective”
dialog. In Eclipse a perspective defines the initial set and
layout of views in the Workbench window.
· Then choose “Window” menu => “Reset Perspectives” and
click “Yes”
* * *
Tip: when taking screenshots of the running result for your
homework report, you may temporarily make the console panel
section bigger so it shows the complete running result.
Afterwards follow the steps above to restore the layout.
* * *
SAVING FILES:
· Naturally, you are required to save your program files. In the
lab, you are required to save your files on a USB flash drive
storage device. If you're working at home, you may save your
files on your computer's hard disk, but you're still required to
have a flash drive so that you can transport your files to and
from school. If you're at the school's lab, do not use the hard
disks ever!
ECLIPSE TUTORIAL:
If you forget how to do something in Eclipse, it is up to you to
carefully reread this Eclipse tutorial and figure out how to do
things. To reduce the number of rereads, go through this tutorial
slowly and try to remember what you're doing.
This tutorial uses x: to refer to the drive that you're saving your
work on. In the lab, x: should be replaced by the USB drive
(assuming that you're using a USB flash drive storage device).
At home, x: should be replaced by the USB drive or the hard
drive, whichever you prefer.
Whenever you are asked to perform an action (left column
below) that you've done before, I will refrain from providing
the supplemental information (right column below). If you don't
remember the details of how to do something, look for it earlier
in the tutorial. I expect you to have to look up a lot of
previously covered material. This is my attempt to force you to
start memorizing how to do things.
Actions
Supplemental Information
Create a workspace.
Selecting Eclipse (above) should cause a "Workspace Launcher”
dialog to appear.
In the “Workspace” box, enter x:219pgms.
Since this is the first time you've specified x:219pgms in the
workspace box, you'll be creating a new workspace – the
219pgms workspace, which is a folder named 219pgms on drive
x: to store your work. If the 219pgms folder doesn't exist,
Eclipse will create it for you.
Make sure the "Use this as a default and do not ask again" box
is unchecked.
Click OK. Eclipse will create the 219pgms workspace and load
a “Welcome” screen. It's not required, but feel free to explore
the “Welcome” screen's links.
Go to the workbench.
The workbench is the area where you'll do all your work –
where you'll enter, debug, and run code. To close the
“Welcome” screen and go to the workbench, click on the
Workbench icon in the top-right corner of the screen. Note you
can get the “Welcome” screen back at any time by choosing
“Help” menu => “Welcome”.
If there was no prompt for workspace.
If you ever load Eclipse and the “Workspace Launcher” dialog
doesn't appear, that means someone checked the "Use this as a
default and do not ask again" box. That's a bad thing
(particularly in the lab) because then all users are taken to the
same workspace location and that location might be
inappropriate. To correct this problem, perform these steps after
getting to the Eclipse workbench:
Choose “Window” menu => “Preferences” to bring out the
“Preferences” window.
In the container tree at the left of the “Preferences” window,
choose “General” => “Startup and Shutdown” => “Workspaces”.
Make sure the "Prompt for workspace on startup" box is
checked and click “OK”.
Make sure you’re using the Java perspective.
Eclipse can be used for many different languages. If the
previous Eclipse user used it for a language other than Java,
switch the Eclipse perspective back to Java.
In the top-right corner of your workspace window, you should
see tabs for the perspectives that Eclipse has used in the past.
Make sure the Java perspective tab is selected. If you want to
select it, but can’t see it as a selection option, choose “Window”
menu => “Open Perspective” => “Other…” and select “Java
(default)” in the “Open Perspective” dialog.
B. Set up the coding style preference
Coding-style preferences - background information.
You'll now set Eclipse's coding-style preferences so they match
the ICS Department's coding-style conventions (the convention
followed in this class).
If you're in the lab, you should import the ICS Department's
preferences file. If you're at your home computer, you should
set your preferences manually (see Eclipse Download tutorial).
How to set your preferences when you're in the lab.
Choose “File” menu => “Import…” to bring out an “Import”
window.
In the container tree at the left of the “Import” window, choose
“General” container=> “Preferences”, and click “Next” button.
In the “Import Preferences” window, click “Browse…” button to
search for and select the cimDeptProfile.epf file in the c:
folder.
Click “Finish” button.
C. Build and run the famous Hello World! Project
What is a project?
A project is an entity that helps to organize all the files in a
particular program. It corresponds to a folder with the same
name in your workspace x:219pgms. For example if you have
created a project named tutorial, then you will have a folder
x:219pgmstutorial created by Eclipse. A project's settings are
stored in a .project file which is contained in the project's
folder.
How to organize your projects.
Normally you should create one new project for each new Java
program (with one or multiple .java class files, but only one of
those classes contains a main() method).
I recommend that you use one workspace to store all your CS
219 projects. In this tutorial, you've already created a 219pgms
workspace and you will create a tutorial project within that
workspace. For your homework assignments, I recommend that
you create hw1, hw2, etc. projects within the 219pgms
workspace.
Create a project.
Choose “File” menu => “New” => “Java Project”.
In the “New Java Project” window, enter tutorial for “Project
name”.
Verify that
· “Use default location” is selected
· In the “JRE” area “Use default JRE” (3rd option) is selected.
The 1st option “Use an execution environment JRE” is okay too
as long as the version is at least 1.7.
· and in the “Project layout” area, “Use project folder as root
for sources and class files” (1st option) is selected.
Click the “Finish” button.
Verify project creation.
Go to “Windows Explorer” and locate the x:219pgmstutorial
folder. Verify the existence of the .project file within the
tutorial folder. If you don't see the tutorial folder, try double
clicking on the 219pgms folder.
Find Package Explorer.
At the left of your Eclipse window, you should see a “Package
Explorer” pane that contains your workspace's project folders.
If the package explorer pane is not shown, open it by choosing
“Window” menu => “Show View” => “Package Explorer”.
Create a class and add to your project.
In the “Package Explorer” pane, right click on the tutorial
project.
Select “New” => “Class” from the pop-up menu.
In the “New Java Class” window,
· In the “Package” field, delete the content if it is not empty.
· In the “Name” field, enter the name of your class Hello.
· Check option (uncheck if this class is not a driver class)
Click the “Finish button”. That should cause an Hello.java with
an empty main() method created and open in the “Editor”
window.
Enter this text:
Enter this text in Hello.java such that <your name> is replaced
with your actual name.
/****************************************
* Hello.java
* <your name>
*
* This program says "hello" to the world.
****************************************/
public class Hello
{
public static void main(String[] args)
{
System.out.println("Hello world!");
} // end main
} // end class Hello
Save the source file.
Press Ctrl+s or click on the save icon in the toolbar.
A source code file with unsaved changes is displayed with an
asterisk preceding its name . Get into the good habit of saving
your work periodically.
Compile and run your program.
There is no need to compile the Java source file explicitly. It is
because Eclipse performs the so-called incremental compilation,
i.e., the Java statement is compiled as and when it is entered.
Any syntax error is detected and signaled immediately in the
“Editor” and suspicious code is underlined, as shown below:
Move your mouse over to view the error message(s). After the
error(s) are fixed those markers will be cleared.
To run the program, right-click anywhere on the source file
Hello.java (or from the “Run” menu) => Choose "Run As" =>
"Java Application".
The output "Hello, world!" appears on the "Console" panel.
If necessary, fix runtime errors (semantic i.e. algorithmic
errors).
D. Create a project by copying from an existing project
Create a second program.
To create a new program, you can of course enter it from
scratch as you did for the Hello.java program. As a shortcut,
this time we'll copy from an existing program and edit the copy.
Create a project and files by copying from an existing project.
In the “Package Explorer” pane, right click on your old tutorial
project and choose “Copy” from the popup menu to copy the
project.
Next right click anywhere in the “Package Explorer” pane and
choose “Paste” from the popup menu. This will bring forth a
“Copy Project” window. Change the project name to counting.
Locate this new counting project in the “Package Explorer”
pane, expand it and look for the (default package) container and
the Hello.java inside. This new project and the Hello.java can
be modified independently of the existing tutorial project.
‘Rename” a Java class
There is no way to directly rename a Java class in Eclipse, but
we can fake it by first making a copy, changing the name of the
copy, and then deleting the original.
In the “Package Explorer” pane, right click on the Hello.java in
your new counting project. Choose “Copy” from the popup
menu or just press Ctrl+c. Next right click on the same
Hello.java or the (default package) in the counting project and
choose “Paste” to create a copy. This will bring forth a “Name
Conflict” dialog and enter Countdown (no need to enter .java)
as the new name. A Countdown.java file will appear in the
project. Double-click on it to open it in the Editor area. Check
the file and you will see that the class name is now Countdown.
You still need to change manually the old name appeared in
comments, such as “xxx.java” in the prolog and “// end class
xxx” at the end of your program.
In the “Package Explorer” pane, right click on the Hello.java in
your counting project and choose “Delete” to remove it from
this project.
Edit the Countdown.java file.
Edit the Countdown.java file so that it contains this:
/****************************************************
* Countdown.java
* <your name>
*
* This program prints a countdown from a user-entered
* starting position.
****************************************************/
import java.util.Scanner;
public class Countdown
{
public static void main(String[] args)
{
int startPos; // starting position for countdown
Scanner stdIn = new Scanner(System.in);
System.out.print("Enter countdown starting position: ");
startPos = stdIn.nextInt();
stdIn.close(); // close stdIn after all input is done.
for (int i=startPos; i>0;)
{
System.out.println(i + "...");
}
System.out.println("Lift off!");
} // end main
} // end class Countdown
Run the program using the run icon.
Compile and run the program as you did for the first program,
but this time run your program using the run icon on the
toolbar.
Type in 30 at the prompt to enter the countdown starting
position in the “Console”. You may notice that the cursor is
flashing at the beginning of the prompt message. Don’t worry.
Just start typing and the cursor will automatically move to
where it should be.
After pressing enter, your “Console” should be filled with
multiple lines of 30...
Wait, why is it going nonstop? (Pause and think for a minute
before proceeding)
E. Terminate a running program
Terminate the program.
Your program is repeatedly printing the line 30... That's an
example of an infinite loop.
Note the red button at the upper-right corner of your “Console”.
The red button allows the user to terminate a program that's
currently running. (Makes sense, right? Red for stop.) Click it
to stop the infinite loop.
Find the error.
An infinite loop is an example of a run-time error.
Run-time errors are often more difficult to debug than
compilation errors because you do not have the benefit of a
compiler-generated error message.
Can you figure out the error?
Do not continue until you have attempted to find the error.
Fix the error and recompile.
That's right, the for loop heading is missing its third component.
Replace the for loop heading with this line:
for (int i=startPos; i>0; i--)
Save Countdown.java and re-run with the same input 30. Your
“Console” should display this:
Enter countdown starting position: 30
30 ...
29 ...
<28 through 2 go here>
1 ...
Lift off!
Note that you'll probably need to scroll up and down to see the
entire output.
- END -
CS 219 - HOMEWORK 0
(Due: Mon, 8/24/2015. Total: 20 pts)
HOMEWORK SUBMISSION POLICIES:
· Put all of your work, even project source code and screenshots
of project output, into a single homework document, and submit
that document to this assignment on Canvas by midnight of the
day that the homework is due. Put your name at the top of that
document.
· Make sure that the problems in your homework document are
in the same order as the problems in the homework assignment.
· In your homework document, make sure that you use
monospace font for your project source code and project output.
The monospace font ensures that text that's supposed to be
aligned stays aligned when it's printed. If your printed source
code is not aligned properly, you will lose style points. To
achieve monospace font, highlight the relevant text, right click,
and select Font. In the Font window, search for Courier New,
select it, and click OK to apply your font selection.
MANDATORY UNGRADED WORK:
· Complete my Get Started with Eclipse in the Computer Lab
tutorial (listed on Canvas ( Modules ( Week1 overview).
· Review Java Coding Conventions Guidelines document (listed
on http://www.park.edu/ics under Software Resources: Tutorials
and Guidelines). You must follow the guidelines found in this
document.
Submit answers for all of the following questions.
EXERCISES (2 pts, ½ pts each):
The first two exercise questions refer to material in the Get
Started with Eclipse in the Computer Lab tutorial mentioned
above.
1. In Eclipse, what is the name of the file that stores a project's
settings? (The project-settings file is different from the file that
stores coding-style preferences.)
2. What button should you click to terminate the currently
running program?
3. Why is it important to use monospace font for program
source code in your homework document?
4. Answer this question AFTER you’ve completed the project
part of this assignment:
What’s the hardest part of this project for you? Please explain.
PROJECT: Party Guest List (18 pts)
The purpose of this project is to review and practice:
· designing a class using UML class diagram
· building a class
· working with projects with one class and one driver class
Write a complete program that stores and prints number of
participants in a party. As part of your program, write a Party
class that implements these members:
· An instance constant that holds the maximum number of
guests.
· Two instance variables that hold, respectively, the actual
number of guests and the party host’s name.
· A constructor that stores the maximum number of guests and
the host’s name, and initialize the actual number of guests to
zero.
· An addGuest method that fakes adding a guest to the guest list
by incrementing the actual number of guests by 1 or prints an
error message if there’s no more room on the guest list (already
full).
· A printParty method that prints the party’s host, actual number
of guests, and the max number of spots.
Draw a UML class diagram for this Party class. Refer to the
UML format in Fig 6.12 of our textbook, but without the driver
class portion nor the local variables portion.
Provide a separate driver class that tests your Party class. Your
driver class should contain this main method:
public static void main(String[] args)
{
Party party = new Party(3, "David Beckham");
party.addGuest("Roberto Baggio");
party.addGuest("Zinedine Zidane");
party.addGuest("Roberto Baggio");
party.addGuest("Johan Cruyff");
party.addGuest("Diego Maradona");
party.printParty();
} // end main
When compiled and run, your driver class and Party class
together should produce this output:
Johan Cruyff cannot come to the party. The guest list is full.
Diego Maradona cannot come to the party. The guest list is full.
David Beckham's party: 3 guests out of 3 spots.
You may have realized that Party class allows a same guest
added to the guest list for more than once, which is bad! This is
a design flaw due to the limitation of our Java knowledge.
Since we don’t know how to store multiple guest names of a
party yet, there is no way to check if a guest is already
registered. But don’t worry we will come back and fix this in a
follow-up assignment after we learn about Array in ch9.
Overall comment your program appropriately. Pay attention to
the standard stuff like coding style, indention, heading, and
curly braces. Double check your code for indentation after you
paste it in your document.
Submission
· In one word document: UML class diagram; source code;
screenshot of running program
· Use the rubric below to check the completeness of your work
before turning it in.
Rubric: CS219, HW1
Item
Points
(Max)
Points (recvd)
Exercise (2 pts)
1
½
2
½
3
½
4
½
Project (14 pts)
UML for Party class
3
An instance constant that holds the maximum number of guests
1
Two instance variables that hold, respectively, the actual
number of guests and the party host’s name
2
A constructor that stores the maximum number of guests and the
host’s name, and initialize the actual number of guests to zero
3
An addGuest method that increments the actual number of
guests by 1 or prints an error message if there’s no more room
on the guest list
3
A printParty method that prints info of the party in the given
format
1½
The project contains two classes: Party class and a separate
driver class
½
General (4 pts)
Your project compiles and runs
½
Program output: correct result and format
½
Programming style
· Meaningful names for constants and variables
· Correct indentation: 2 spaces for each level
1
Comments
· Prolog
· End of section comments: end of class, end of method, end of
loop etc.
· Document each variable
· Proper comments in the program
2
Penalty
Extra instance/class variables/methods
(- 1)
No copy of code in document
(- 1)
No screenshot of execution result
(- 1)
Total:
20
- END -

More Related Content

Similar to Page 8 of 83.Tutorial Get Started with Eclipse in the Compute.docx

Single Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code baseSingle Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code baseRalf Sternberg
 
Hello world pascal tutorial
Hello world pascal tutorialHello world pascal tutorial
Hello world pascal tutorialSerghei Urban
 
Improve Your IBM Domino Designer Experience
Improve Your IBM Domino Designer ExperienceImprove Your IBM Domino Designer Experience
Improve Your IBM Domino Designer Experiencepanagenda
 
intro-to-eclipse.pdf
intro-to-eclipse.pdfintro-to-eclipse.pdf
intro-to-eclipse.pdfSajeev P
 
Installing and setting up eclipse java projects
Installing and setting up eclipse java projectsInstalling and setting up eclipse java projects
Installing and setting up eclipse java projectshccit
 
Supplement2d netbeans6
Supplement2d netbeans6Supplement2d netbeans6
Supplement2d netbeans6olveraadrian82
 
Eclipse - GUI Palette
Eclipse - GUI Palette Eclipse - GUI Palette
Eclipse - GUI Palette Arpana Awasthi
 
Cis 355 ilab 1 of 6
Cis 355 ilab 1 of 6Cis 355 ilab 1 of 6
Cis 355 ilab 1 of 6comp274
 
Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6solutionjug4
 
Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6helpido9
 
Introduction to Eclipse
Introduction to Eclipse Introduction to Eclipse
Introduction to Eclipse Arpana Awasthi
 
Cross-platform Desktop Apps development using HTML, CSS, JS with Electron
Cross-platform Desktop Apps development using HTML, CSS, JS with ElectronCross-platform Desktop Apps development using HTML, CSS, JS with Electron
Cross-platform Desktop Apps development using HTML, CSS, JS with ElectronEsinniobiwa Quareeb
 
03 eclipse basics & hello world
03   eclipse basics & hello world03   eclipse basics & hello world
03 eclipse basics & hello worldZeeshan-Shaikh
 
How to deploy a j2ee application
How to deploy a j2ee applicationHow to deploy a j2ee application
How to deploy a j2ee applicationKumar
 

Similar to Page 8 of 83.Tutorial Get Started with Eclipse in the Compute.docx (20)

Single Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code baseSingle Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code base
 
Hello world pascal tutorial
Hello world pascal tutorialHello world pascal tutorial
Hello world pascal tutorial
 
Improve Your IBM Domino Designer Experience
Improve Your IBM Domino Designer ExperienceImprove Your IBM Domino Designer Experience
Improve Your IBM Domino Designer Experience
 
Android programming-basics
Android programming-basicsAndroid programming-basics
Android programming-basics
 
intro-to-eclipse.pdf
intro-to-eclipse.pdfintro-to-eclipse.pdf
intro-to-eclipse.pdf
 
Installing and setting up eclipse java projects
Installing and setting up eclipse java projectsInstalling and setting up eclipse java projects
Installing and setting up eclipse java projects
 
Supplement2d netbeans6
Supplement2d netbeans6Supplement2d netbeans6
Supplement2d netbeans6
 
Supplement2d netbeans6
Supplement2d netbeans6Supplement2d netbeans6
Supplement2d netbeans6
 
Eclipse - GUI Palette
Eclipse - GUI Palette Eclipse - GUI Palette
Eclipse - GUI Palette
 
Cis 355 ilab 1 of 6
Cis 355 ilab 1 of 6Cis 355 ilab 1 of 6
Cis 355 ilab 1 of 6
 
Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6
 
Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6
 
Introduction to Eclipse
Introduction to Eclipse Introduction to Eclipse
Introduction to Eclipse
 
How java works
How java worksHow java works
How java works
 
How java works
How java worksHow java works
How java works
 
Cross-platform Desktop Apps development using HTML, CSS, JS with Electron
Cross-platform Desktop Apps development using HTML, CSS, JS with ElectronCross-platform Desktop Apps development using HTML, CSS, JS with Electron
Cross-platform Desktop Apps development using HTML, CSS, JS with Electron
 
03 eclipse basics & hello world
03   eclipse basics & hello world03   eclipse basics & hello world
03 eclipse basics & hello world
 
Installing the java sdk
Installing the java sdkInstalling the java sdk
Installing the java sdk
 
How to deploy a j2ee application
How to deploy a j2ee applicationHow to deploy a j2ee application
How to deploy a j2ee application
 
Windows 10 Error 1603
Windows 10 Error 1603Windows 10 Error 1603
Windows 10 Error 1603
 

More from alfred4lewis58146

For this assignment, students will need to observe the activities th.docx
For this assignment, students will need to observe the activities th.docxFor this assignment, students will need to observe the activities th.docx
For this assignment, students will need to observe the activities th.docxalfred4lewis58146
 
For this assignment, select a human service organization from .docx
For this assignment, select a human service organization from .docxFor this assignment, select a human service organization from .docx
For this assignment, select a human service organization from .docxalfred4lewis58146
 
For this Assignment, read the case study for Claudia and find tw.docx
For this Assignment, read the case study for Claudia and find tw.docxFor this Assignment, read the case study for Claudia and find tw.docx
For this Assignment, read the case study for Claudia and find tw.docxalfred4lewis58146
 
For this assignment, download the A6 code pack. This zip fil.docx
For this assignment, download the A6 code pack. This zip fil.docxFor this assignment, download the A6 code pack. This zip fil.docx
For this assignment, download the A6 code pack. This zip fil.docxalfred4lewis58146
 
For this assignment, create infographic using the Canva website..docx
For this assignment, create infographic using the Canva website..docxFor this assignment, create infographic using the Canva website..docx
For this assignment, create infographic using the Canva website..docxalfred4lewis58146
 
For this assignment, compare  California during the Great Depression.docx
For this assignment, compare  California during the Great Depression.docxFor this assignment, compare  California during the Great Depression.docx
For this assignment, compare  California during the Great Depression.docxalfred4lewis58146
 
For this assignment, create a 10- to 12-slide presentation in Mi.docx
For this assignment, create a 10- to 12-slide presentation in Mi.docxFor this assignment, create a 10- to 12-slide presentation in Mi.docx
For this assignment, create a 10- to 12-slide presentation in Mi.docxalfred4lewis58146
 
For this assignment, begin by reading chapters 12-15 in Dr. Bells t.docx
For this assignment, begin by reading chapters 12-15 in Dr. Bells t.docxFor this assignment, begin by reading chapters 12-15 in Dr. Bells t.docx
For this assignment, begin by reading chapters 12-15 in Dr. Bells t.docxalfred4lewis58146
 
For this assignment, assume you are the new Secretary of Homelan.docx
For this assignment, assume you are the new Secretary of Homelan.docxFor this assignment, assume you are the new Secretary of Homelan.docx
For this assignment, assume you are the new Secretary of Homelan.docxalfred4lewis58146
 
For this assignment, address the following promptsIntroductor.docx
For this assignment, address the following promptsIntroductor.docxFor this assignment, address the following promptsIntroductor.docx
For this assignment, address the following promptsIntroductor.docxalfred4lewis58146
 
For this assignment, analyze the play by focusing on one of the .docx
For this assignment, analyze the play by focusing on one of the .docxFor this assignment, analyze the play by focusing on one of the .docx
For this assignment, analyze the play by focusing on one of the .docxalfred4lewis58146
 
For this assignment I would like you to answer these questions.docx
For this assignment I would like you to answer these questions.docxFor this assignment I would like you to answer these questions.docx
For this assignment I would like you to answer these questions.docxalfred4lewis58146
 
For the Weekly Reports I need 2 reports. For the First two weeks the.docx
For the Weekly Reports I need 2 reports. For the First two weeks the.docxFor the Weekly Reports I need 2 reports. For the First two weeks the.docx
For the Weekly Reports I need 2 reports. For the First two weeks the.docxalfred4lewis58146
 
For the shortanswer questions,you will need to respo.docx
For the shortanswer questions,you will need to respo.docxFor the shortanswer questions,you will need to respo.docx
For the shortanswer questions,you will need to respo.docxalfred4lewis58146
 
For the sake of argument (this essay in particular), lets prete.docx
For the sake of argument (this essay in particular), lets prete.docxFor the sake of argument (this essay in particular), lets prete.docx
For the sake of argument (this essay in particular), lets prete.docxalfred4lewis58146
 
For the proposal, each student must describe an interface they a.docx
For the proposal, each student must describe an interface they a.docxFor the proposal, each student must describe an interface they a.docx
For the proposal, each student must describe an interface they a.docxalfred4lewis58146
 
For the project, you will be expected to apply the key concepts of p.docx
For the project, you will be expected to apply the key concepts of p.docxFor the project, you will be expected to apply the key concepts of p.docx
For the project, you will be expected to apply the key concepts of p.docxalfred4lewis58146
 
For the past several weeks you have addressed several different area.docx
For the past several weeks you have addressed several different area.docxFor the past several weeks you have addressed several different area.docx
For the past several weeks you have addressed several different area.docxalfred4lewis58146
 
For the Mash it Up assignment, we experimented with different ways t.docx
For the Mash it Up assignment, we experimented with different ways t.docxFor the Mash it Up assignment, we experimented with different ways t.docx
For the Mash it Up assignment, we experimented with different ways t.docxalfred4lewis58146
 
For the first time in modern history, the world is experiencing a he.docx
For the first time in modern history, the world is experiencing a he.docxFor the first time in modern history, the world is experiencing a he.docx
For the first time in modern history, the world is experiencing a he.docxalfred4lewis58146
 

More from alfred4lewis58146 (20)

For this assignment, students will need to observe the activities th.docx
For this assignment, students will need to observe the activities th.docxFor this assignment, students will need to observe the activities th.docx
For this assignment, students will need to observe the activities th.docx
 
For this assignment, select a human service organization from .docx
For this assignment, select a human service organization from .docxFor this assignment, select a human service organization from .docx
For this assignment, select a human service organization from .docx
 
For this Assignment, read the case study for Claudia and find tw.docx
For this Assignment, read the case study for Claudia and find tw.docxFor this Assignment, read the case study for Claudia and find tw.docx
For this Assignment, read the case study for Claudia and find tw.docx
 
For this assignment, download the A6 code pack. This zip fil.docx
For this assignment, download the A6 code pack. This zip fil.docxFor this assignment, download the A6 code pack. This zip fil.docx
For this assignment, download the A6 code pack. This zip fil.docx
 
For this assignment, create infographic using the Canva website..docx
For this assignment, create infographic using the Canva website..docxFor this assignment, create infographic using the Canva website..docx
For this assignment, create infographic using the Canva website..docx
 
For this assignment, compare  California during the Great Depression.docx
For this assignment, compare  California during the Great Depression.docxFor this assignment, compare  California during the Great Depression.docx
For this assignment, compare  California during the Great Depression.docx
 
For this assignment, create a 10- to 12-slide presentation in Mi.docx
For this assignment, create a 10- to 12-slide presentation in Mi.docxFor this assignment, create a 10- to 12-slide presentation in Mi.docx
For this assignment, create a 10- to 12-slide presentation in Mi.docx
 
For this assignment, begin by reading chapters 12-15 in Dr. Bells t.docx
For this assignment, begin by reading chapters 12-15 in Dr. Bells t.docxFor this assignment, begin by reading chapters 12-15 in Dr. Bells t.docx
For this assignment, begin by reading chapters 12-15 in Dr. Bells t.docx
 
For this assignment, assume you are the new Secretary of Homelan.docx
For this assignment, assume you are the new Secretary of Homelan.docxFor this assignment, assume you are the new Secretary of Homelan.docx
For this assignment, assume you are the new Secretary of Homelan.docx
 
For this assignment, address the following promptsIntroductor.docx
For this assignment, address the following promptsIntroductor.docxFor this assignment, address the following promptsIntroductor.docx
For this assignment, address the following promptsIntroductor.docx
 
For this assignment, analyze the play by focusing on one of the .docx
For this assignment, analyze the play by focusing on one of the .docxFor this assignment, analyze the play by focusing on one of the .docx
For this assignment, analyze the play by focusing on one of the .docx
 
For this assignment I would like you to answer these questions.docx
For this assignment I would like you to answer these questions.docxFor this assignment I would like you to answer these questions.docx
For this assignment I would like you to answer these questions.docx
 
For the Weekly Reports I need 2 reports. For the First two weeks the.docx
For the Weekly Reports I need 2 reports. For the First two weeks the.docxFor the Weekly Reports I need 2 reports. For the First two weeks the.docx
For the Weekly Reports I need 2 reports. For the First two weeks the.docx
 
For the shortanswer questions,you will need to respo.docx
For the shortanswer questions,you will need to respo.docxFor the shortanswer questions,you will need to respo.docx
For the shortanswer questions,you will need to respo.docx
 
For the sake of argument (this essay in particular), lets prete.docx
For the sake of argument (this essay in particular), lets prete.docxFor the sake of argument (this essay in particular), lets prete.docx
For the sake of argument (this essay in particular), lets prete.docx
 
For the proposal, each student must describe an interface they a.docx
For the proposal, each student must describe an interface they a.docxFor the proposal, each student must describe an interface they a.docx
For the proposal, each student must describe an interface they a.docx
 
For the project, you will be expected to apply the key concepts of p.docx
For the project, you will be expected to apply the key concepts of p.docxFor the project, you will be expected to apply the key concepts of p.docx
For the project, you will be expected to apply the key concepts of p.docx
 
For the past several weeks you have addressed several different area.docx
For the past several weeks you have addressed several different area.docxFor the past several weeks you have addressed several different area.docx
For the past several weeks you have addressed several different area.docx
 
For the Mash it Up assignment, we experimented with different ways t.docx
For the Mash it Up assignment, we experimented with different ways t.docxFor the Mash it Up assignment, we experimented with different ways t.docx
For the Mash it Up assignment, we experimented with different ways t.docx
 
For the first time in modern history, the world is experiencing a he.docx
For the first time in modern history, the world is experiencing a he.docxFor the first time in modern history, the world is experiencing a he.docx
For the first time in modern history, the world is experiencing a he.docx
 

Recently uploaded

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 

Recently uploaded (20)

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 

Page 8 of 83.Tutorial Get Started with Eclipse in the Compute.docx

  • 1. Page 8 of 8 3.Tutorial: Get Started with Eclipse in the Computer Lab[footnoteRef:1] [1: This tutorial is modified from Eclipse Tutorial – Getting Started by Dr. John Dean (http://captain.park.edu/jdean/tutorials/eclipseDnldTutorial.doc ) and How To Install Eclipse and Get Started with Java Programming from https://www3.ntu.edu.sg/home/ehchua/programming/howto/Ecli pseJava_HowTo.html (retrieved on 8/8/2015)] (Last updated: 8/16/2015) In this tutorial you will practice using Eclipse to build Java programs in computer labs (such as SC113) on campus. We will practice: A. Get familiar with the Eclipse IDE B. Set up the coding style preference (such as two-space indent and soft tab) used in this course C. Build and run the famous Hello World! Project D. Create a project by copying from an existing project E. Terminate a running program * * * Eclipse is an Integrated Development Environment (IDE) that allows you to enter, compile, and run programs. The programs can be written in one of many different languages, such of Java, C/C++, and PHP. Computer labs on campus already has Eclipse ready for Java development. The screenshot below shows the default layout of Eclipse. Take a look now and refer back to this screenshot as to where things are while you work through this tutorial.
  • 2. 1. Menu 2. Toolbar 3. Package Explorer: display all your projects and files. Yours will be empty at this point. 4. Editor 5. Outline view: displays data and method members of the currently selected Java class 6. Console panel If you accidentally closed or moved one of the panels above, you can always restore this default layout by: · First choose “Window” menu => “Open Perspective” => “Other…” and select “Java (default)” in the “Open Perspective” dialog. In Eclipse a perspective defines the initial set and layout of views in the Workbench window. · Then choose “Window” menu => “Reset Perspectives” and click “Yes” * * * Tip: when taking screenshots of the running result for your homework report, you may temporarily make the console panel section bigger so it shows the complete running result. Afterwards follow the steps above to restore the layout. * * * SAVING FILES: · Naturally, you are required to save your program files. In the lab, you are required to save your files on a USB flash drive storage device. If you're working at home, you may save your files on your computer's hard disk, but you're still required to have a flash drive so that you can transport your files to and from school. If you're at the school's lab, do not use the hard disks ever!
  • 3. ECLIPSE TUTORIAL: If you forget how to do something in Eclipse, it is up to you to carefully reread this Eclipse tutorial and figure out how to do things. To reduce the number of rereads, go through this tutorial slowly and try to remember what you're doing. This tutorial uses x: to refer to the drive that you're saving your work on. In the lab, x: should be replaced by the USB drive (assuming that you're using a USB flash drive storage device). At home, x: should be replaced by the USB drive or the hard drive, whichever you prefer. Whenever you are asked to perform an action (left column below) that you've done before, I will refrain from providing the supplemental information (right column below). If you don't remember the details of how to do something, look for it earlier in the tutorial. I expect you to have to look up a lot of previously covered material. This is my attempt to force you to start memorizing how to do things. Actions Supplemental Information Create a workspace. Selecting Eclipse (above) should cause a "Workspace Launcher” dialog to appear. In the “Workspace” box, enter x:219pgms. Since this is the first time you've specified x:219pgms in the workspace box, you'll be creating a new workspace – the 219pgms workspace, which is a folder named 219pgms on drive x: to store your work. If the 219pgms folder doesn't exist, Eclipse will create it for you.
  • 4. Make sure the "Use this as a default and do not ask again" box is unchecked. Click OK. Eclipse will create the 219pgms workspace and load a “Welcome” screen. It's not required, but feel free to explore the “Welcome” screen's links. Go to the workbench. The workbench is the area where you'll do all your work – where you'll enter, debug, and run code. To close the “Welcome” screen and go to the workbench, click on the Workbench icon in the top-right corner of the screen. Note you can get the “Welcome” screen back at any time by choosing “Help” menu => “Welcome”. If there was no prompt for workspace. If you ever load Eclipse and the “Workspace Launcher” dialog doesn't appear, that means someone checked the "Use this as a default and do not ask again" box. That's a bad thing (particularly in the lab) because then all users are taken to the same workspace location and that location might be inappropriate. To correct this problem, perform these steps after getting to the Eclipse workbench: Choose “Window” menu => “Preferences” to bring out the “Preferences” window. In the container tree at the left of the “Preferences” window, choose “General” => “Startup and Shutdown” => “Workspaces”. Make sure the "Prompt for workspace on startup" box is checked and click “OK”. Make sure you’re using the Java perspective. Eclipse can be used for many different languages. If the previous Eclipse user used it for a language other than Java, switch the Eclipse perspective back to Java.
  • 5. In the top-right corner of your workspace window, you should see tabs for the perspectives that Eclipse has used in the past. Make sure the Java perspective tab is selected. If you want to select it, but can’t see it as a selection option, choose “Window” menu => “Open Perspective” => “Other…” and select “Java (default)” in the “Open Perspective” dialog. B. Set up the coding style preference Coding-style preferences - background information. You'll now set Eclipse's coding-style preferences so they match the ICS Department's coding-style conventions (the convention followed in this class). If you're in the lab, you should import the ICS Department's preferences file. If you're at your home computer, you should set your preferences manually (see Eclipse Download tutorial). How to set your preferences when you're in the lab. Choose “File” menu => “Import…” to bring out an “Import” window. In the container tree at the left of the “Import” window, choose “General” container=> “Preferences”, and click “Next” button. In the “Import Preferences” window, click “Browse…” button to search for and select the cimDeptProfile.epf file in the c: folder. Click “Finish” button. C. Build and run the famous Hello World! Project What is a project? A project is an entity that helps to organize all the files in a particular program. It corresponds to a folder with the same name in your workspace x:219pgms. For example if you have created a project named tutorial, then you will have a folder x:219pgmstutorial created by Eclipse. A project's settings are
  • 6. stored in a .project file which is contained in the project's folder. How to organize your projects. Normally you should create one new project for each new Java program (with one or multiple .java class files, but only one of those classes contains a main() method). I recommend that you use one workspace to store all your CS 219 projects. In this tutorial, you've already created a 219pgms workspace and you will create a tutorial project within that workspace. For your homework assignments, I recommend that you create hw1, hw2, etc. projects within the 219pgms workspace. Create a project. Choose “File” menu => “New” => “Java Project”. In the “New Java Project” window, enter tutorial for “Project name”. Verify that · “Use default location” is selected · In the “JRE” area “Use default JRE” (3rd option) is selected. The 1st option “Use an execution environment JRE” is okay too as long as the version is at least 1.7. · and in the “Project layout” area, “Use project folder as root for sources and class files” (1st option) is selected. Click the “Finish” button. Verify project creation. Go to “Windows Explorer” and locate the x:219pgmstutorial folder. Verify the existence of the .project file within the tutorial folder. If you don't see the tutorial folder, try double clicking on the 219pgms folder.
  • 7. Find Package Explorer. At the left of your Eclipse window, you should see a “Package Explorer” pane that contains your workspace's project folders. If the package explorer pane is not shown, open it by choosing “Window” menu => “Show View” => “Package Explorer”. Create a class and add to your project. In the “Package Explorer” pane, right click on the tutorial project. Select “New” => “Class” from the pop-up menu. In the “New Java Class” window, · In the “Package” field, delete the content if it is not empty. · In the “Name” field, enter the name of your class Hello. · Check option (uncheck if this class is not a driver class) Click the “Finish button”. That should cause an Hello.java with an empty main() method created and open in the “Editor” window. Enter this text: Enter this text in Hello.java such that <your name> is replaced with your actual name. /**************************************** * Hello.java * <your name> * * This program says "hello" to the world. ****************************************/ public class Hello { public static void main(String[] args) {
  • 8. System.out.println("Hello world!"); } // end main } // end class Hello Save the source file. Press Ctrl+s or click on the save icon in the toolbar. A source code file with unsaved changes is displayed with an asterisk preceding its name . Get into the good habit of saving your work periodically. Compile and run your program. There is no need to compile the Java source file explicitly. It is because Eclipse performs the so-called incremental compilation, i.e., the Java statement is compiled as and when it is entered. Any syntax error is detected and signaled immediately in the “Editor” and suspicious code is underlined, as shown below: Move your mouse over to view the error message(s). After the error(s) are fixed those markers will be cleared. To run the program, right-click anywhere on the source file Hello.java (or from the “Run” menu) => Choose "Run As" => "Java Application". The output "Hello, world!" appears on the "Console" panel. If necessary, fix runtime errors (semantic i.e. algorithmic errors).
  • 9. D. Create a project by copying from an existing project Create a second program. To create a new program, you can of course enter it from scratch as you did for the Hello.java program. As a shortcut, this time we'll copy from an existing program and edit the copy. Create a project and files by copying from an existing project. In the “Package Explorer” pane, right click on your old tutorial project and choose “Copy” from the popup menu to copy the project. Next right click anywhere in the “Package Explorer” pane and choose “Paste” from the popup menu. This will bring forth a “Copy Project” window. Change the project name to counting. Locate this new counting project in the “Package Explorer” pane, expand it and look for the (default package) container and the Hello.java inside. This new project and the Hello.java can be modified independently of the existing tutorial project. ‘Rename” a Java class There is no way to directly rename a Java class in Eclipse, but we can fake it by first making a copy, changing the name of the copy, and then deleting the original. In the “Package Explorer” pane, right click on the Hello.java in your new counting project. Choose “Copy” from the popup menu or just press Ctrl+c. Next right click on the same Hello.java or the (default package) in the counting project and choose “Paste” to create a copy. This will bring forth a “Name Conflict” dialog and enter Countdown (no need to enter .java) as the new name. A Countdown.java file will appear in the project. Double-click on it to open it in the Editor area. Check the file and you will see that the class name is now Countdown. You still need to change manually the old name appeared in comments, such as “xxx.java” in the prolog and “// end class
  • 10. xxx” at the end of your program. In the “Package Explorer” pane, right click on the Hello.java in your counting project and choose “Delete” to remove it from this project. Edit the Countdown.java file. Edit the Countdown.java file so that it contains this: /**************************************************** * Countdown.java * <your name> * * This program prints a countdown from a user-entered * starting position. ****************************************************/ import java.util.Scanner; public class Countdown { public static void main(String[] args) { int startPos; // starting position for countdown Scanner stdIn = new Scanner(System.in); System.out.print("Enter countdown starting position: "); startPos = stdIn.nextInt(); stdIn.close(); // close stdIn after all input is done. for (int i=startPos; i>0;) { System.out.println(i + "..."); } System.out.println("Lift off!"); } // end main } // end class Countdown
  • 11. Run the program using the run icon. Compile and run the program as you did for the first program, but this time run your program using the run icon on the toolbar. Type in 30 at the prompt to enter the countdown starting position in the “Console”. You may notice that the cursor is flashing at the beginning of the prompt message. Don’t worry. Just start typing and the cursor will automatically move to where it should be. After pressing enter, your “Console” should be filled with multiple lines of 30... Wait, why is it going nonstop? (Pause and think for a minute before proceeding) E. Terminate a running program Terminate the program. Your program is repeatedly printing the line 30... That's an example of an infinite loop. Note the red button at the upper-right corner of your “Console”. The red button allows the user to terminate a program that's currently running. (Makes sense, right? Red for stop.) Click it to stop the infinite loop. Find the error. An infinite loop is an example of a run-time error. Run-time errors are often more difficult to debug than compilation errors because you do not have the benefit of a compiler-generated error message. Can you figure out the error?
  • 12. Do not continue until you have attempted to find the error. Fix the error and recompile. That's right, the for loop heading is missing its third component. Replace the for loop heading with this line: for (int i=startPos; i>0; i--) Save Countdown.java and re-run with the same input 30. Your “Console” should display this: Enter countdown starting position: 30 30 ... 29 ... <28 through 2 go here> 1 ... Lift off! Note that you'll probably need to scroll up and down to see the entire output. - END - CS 219 - HOMEWORK 0 (Due: Mon, 8/24/2015. Total: 20 pts) HOMEWORK SUBMISSION POLICIES: · Put all of your work, even project source code and screenshots of project output, into a single homework document, and submit that document to this assignment on Canvas by midnight of the day that the homework is due. Put your name at the top of that document. · Make sure that the problems in your homework document are in the same order as the problems in the homework assignment.
  • 13. · In your homework document, make sure that you use monospace font for your project source code and project output. The monospace font ensures that text that's supposed to be aligned stays aligned when it's printed. If your printed source code is not aligned properly, you will lose style points. To achieve monospace font, highlight the relevant text, right click, and select Font. In the Font window, search for Courier New, select it, and click OK to apply your font selection. MANDATORY UNGRADED WORK: · Complete my Get Started with Eclipse in the Computer Lab tutorial (listed on Canvas ( Modules ( Week1 overview). · Review Java Coding Conventions Guidelines document (listed on http://www.park.edu/ics under Software Resources: Tutorials and Guidelines). You must follow the guidelines found in this document. Submit answers for all of the following questions. EXERCISES (2 pts, ½ pts each): The first two exercise questions refer to material in the Get Started with Eclipse in the Computer Lab tutorial mentioned above. 1. In Eclipse, what is the name of the file that stores a project's settings? (The project-settings file is different from the file that stores coding-style preferences.) 2. What button should you click to terminate the currently running program? 3. Why is it important to use monospace font for program source code in your homework document? 4. Answer this question AFTER you’ve completed the project part of this assignment:
  • 14. What’s the hardest part of this project for you? Please explain. PROJECT: Party Guest List (18 pts) The purpose of this project is to review and practice: · designing a class using UML class diagram · building a class · working with projects with one class and one driver class Write a complete program that stores and prints number of participants in a party. As part of your program, write a Party class that implements these members: · An instance constant that holds the maximum number of guests. · Two instance variables that hold, respectively, the actual number of guests and the party host’s name. · A constructor that stores the maximum number of guests and the host’s name, and initialize the actual number of guests to zero. · An addGuest method that fakes adding a guest to the guest list by incrementing the actual number of guests by 1 or prints an error message if there’s no more room on the guest list (already full). · A printParty method that prints the party’s host, actual number of guests, and the max number of spots. Draw a UML class diagram for this Party class. Refer to the UML format in Fig 6.12 of our textbook, but without the driver class portion nor the local variables portion.
  • 15. Provide a separate driver class that tests your Party class. Your driver class should contain this main method: public static void main(String[] args) { Party party = new Party(3, "David Beckham"); party.addGuest("Roberto Baggio"); party.addGuest("Zinedine Zidane"); party.addGuest("Roberto Baggio"); party.addGuest("Johan Cruyff"); party.addGuest("Diego Maradona"); party.printParty(); } // end main When compiled and run, your driver class and Party class together should produce this output: Johan Cruyff cannot come to the party. The guest list is full. Diego Maradona cannot come to the party. The guest list is full. David Beckham's party: 3 guests out of 3 spots. You may have realized that Party class allows a same guest added to the guest list for more than once, which is bad! This is a design flaw due to the limitation of our Java knowledge. Since we don’t know how to store multiple guest names of a party yet, there is no way to check if a guest is already registered. But don’t worry we will come back and fix this in a
  • 16. follow-up assignment after we learn about Array in ch9. Overall comment your program appropriately. Pay attention to the standard stuff like coding style, indention, heading, and curly braces. Double check your code for indentation after you paste it in your document. Submission · In one word document: UML class diagram; source code; screenshot of running program · Use the rubric below to check the completeness of your work before turning it in. Rubric: CS219, HW1 Item Points (Max) Points (recvd) Exercise (2 pts) 1 ½ 2 ½ 3 ½ 4 ½
  • 17. Project (14 pts) UML for Party class 3 An instance constant that holds the maximum number of guests 1 Two instance variables that hold, respectively, the actual number of guests and the party host’s name 2 A constructor that stores the maximum number of guests and the host’s name, and initialize the actual number of guests to zero 3 An addGuest method that increments the actual number of guests by 1 or prints an error message if there’s no more room on the guest list 3 A printParty method that prints info of the party in the given format 1½ The project contains two classes: Party class and a separate driver class ½
  • 18. General (4 pts) Your project compiles and runs ½ Program output: correct result and format ½ Programming style · Meaningful names for constants and variables · Correct indentation: 2 spaces for each level 1 Comments · Prolog · End of section comments: end of class, end of method, end of loop etc. · Document each variable · Proper comments in the program 2
  • 19. Penalty Extra instance/class variables/methods (- 1) No copy of code in document (- 1) No screenshot of execution result (- 1) Total: 20 - END -