CS1027b Computer Science Fundamentals II
General lab instructions to help labs run smoothly
- Read through the lab instructions before coming to the lab.
- Do the pre-lab preparation.
- Bring a printed copy of the lab instructions to the lab.
Overview and preparation
We use Eclipse as our Integrated Development Environment, available on
the Computer Science Department machines in the Undergrad Labs used as
the First Year Teaching Environment (MC 8, 10, 230, 235).
- You can download Eclipse for your own computer from the
Eclipse Website. See the
tutorials and information posted in the course's webpage about how to install
java and Eclipse on your computer.
- If you have not used Eclipse, you may want to read the Workbench
User Guide in the on-line help which comes with Eclipse (on the top menu,
select "Help" and then select "Help Contents").
Upon completion of this lab, you should be able to do the following in the Eclipse environment:
IMPORTANT: Make sure you show the result(s) of each Exercise to your TA AND you submit your .java files through OWL to get your marks for the lab.
- Create a new project containing new source files.
- Create a new project from existing source files.
Suggested project organization
In an Integrated Development Environments such as Eclipse, Netbeans,
VisualStudio, etc. we need to create a project in order to run an
application program. Most applications consist of multiple files. A
project contains all the information about the program, such as a list
of program files (source files, class files), IDE settings, and
properties. In CS1027, you will create a new project in Eclipse for
every application that you wish to run.
Create a folder called (for example) Eclipse or CS1027b to hold all
your Eclipse projects for this course. This will contain the project
files themselves. The Java source files may be in this folder also (as
in Exercises 1 and 3), or in some other (external) folder (as in
Exercise 1: Getting Started with Eclipse
Exercise 2: Creating a New Project from Existing Source Files
In this exercise, you will create a new project to run the sample
Social Networking application whose files are posted on the
code Section of the CS1027 Course web page. (We will not
concern ourselves with what this code does at present; you will merely
use the files to practice this part of the Lab.)
- Create a new folder in your disk area called SocialNetworking (not in your
Download the .java files from the "Object Oriented Programming" section of
and store them into that folder.
- In Eclipse, select File, New, Java Project from the top menu.
Enter the project
- Uncheck Use default location, and browse to find the folder where you stored
the above java files. Click Finish at the bottom of the window.
- Go to the Package Explorer window and select the SocialNetworking project (click on
the ">" symbol to the left of the name of the project). Select "(default package)" by clicking on the ">" symbol to its left.
- You will get a compiler error from
little red "X" at the bottom left corner of the icon for Myfrieds.java),
since the provided code does not yet have the
getNumFriends() method defined in
Double click on the MyFriends.java icon. You can do either of two things to fix this:
- Comment out the offending line of code in
"//" at the beginning of this line)
getNumFriends() method to
SocialNetwork.java (we will be doing this in Lab 2 in any case)
- From the top menu, select Run in order to run the application. The results should be visible in the Console window.
- The output of the program should be a list of contacts and their email addresses.
- Close the project.
Exercise 3: Creating a New Java Program
- Create a new project called MyName in your project folder.
- Create a new class called MyName that has a
main method that displays your name and email address on the screen.
- Run your MyName program and make sure it works correctly.
- Close the project.