CSE 115 - Spring 2007 - Banner
   CSE 115 - Spring 2007 - Introduction to Computer Science for Majors I
CSE 115 - Spring 2007 - Left Navigation CSE 115 - Spring 2007 - Lab 2

Lab 2 (Working at Home)

Introduction

There will probably be times throughout this semester that you would like to work at a location other than the Baldy lab. In order to do this, you must prepare your home machine by installing the correct tools needed to do the work for this class. This lab will mimic the Lab 2 you just completed in recitation, but will allow you to start on the process to getting your home computer ready for the semester.


Objectives

The high-level objectives of this lab are to have you,
  • set up and customize Eclipse for CSE115,
  • familiarize yourself with the Eclipse environment,
  • create and edit some more text files using Eclipse,
  • compile, debug and run a small Java applet, and
  • learn how to use the JAR utility to create JAR files to submit your work
The following are the new concepts covered in this lab:
  • using CVS repositories
  • Eclipse environment vocabulary
  • declaring classes,
  • defining constructors,
  • instantiating classes using the new operator,
  • using the Applet class.
  • creating a JAR file

Assignment Specifications

Sometimes, even the most complex programs are simpler than they seem to create. In this lab, you will create a fairly sophisticated program using some pre-built components. In fact, this idea of taking components that are already built and using them to create a different program is central to how quite a bit of software is actually developed today. Most companies do not build all of their own software from scratch. Instead, they purchase bundles of software that gives them the required functionality that they need and the company uses and customized the software as appropriate. The only thing you are required to do for this lab is to have your program create an instance of a pre-built component named lab2lib.Lab2Program and your work is complete.


Helpful Hints

Read through the entire lab before you start working, so that you know what to expect. Make sure you save your work often, and keep track of what you are expected to submit.

Do not be afraid to refer to earlier labs to recall what things mean or what commands are available for you to use.


Reading

Make sure you have read chapter 1 and chapter 2 of the book before coming to lab. Also make sure you have reviewed your lecture notes. It might also be helpful to begin looking at Chapter 1 of the Eclipse book.


Lab set-up tasks

At your lab session your teaching assistant will briefly discuss how to carry out each of the set-up tasks below. She or he will also be available to answer questions you might have. Before you start work on the lab itself, you must carry out each of the following set-up tasks. Your teaching assistant will guide you through this process.

If you are trying to do this lab from Baldy 21, you are reading the wrong page, please consult this link.

Step 1: Turn on computer and create a connection to the Internet

This process will vary from machine to machine, so hopefully you can do this on your computer.

Step 2: Install Appropriate Software

First, from the TechTools CD (see http://wings.buffalo.edu/computing/software/ if you do not have the CD) download:

  • FileZilla
  • PuTTY
  • XWin32 or UBVPN

All of these programs are located under Utilities. Follow the instructions for download and install all the programs. If you are working on a Mac, you do not need either of the first two. See notes for Mac about FTP. You also have a way to make a connection to a terminal built-in. You can download the VPN client if you'd like. Directions for using PuTTY/ creating a connection to a terminal window are located here. Follow them and create a connection to styx.cse.buffalo.edu no matter which kind of computer you are using. Now, you are logged into the same computer that you log into in the lab. Type the ls command at the prompt so you can see all the files in your directory.

 

Second, read the directions for Installing Eclipse and Plug-ins. You first need to download the JDK and then you need to download the Eclipse self-installer. (Directions for Macs are a little different, please make sure you are reading the correct directions). For now, DO NOT install anything from the section entitled "Installing UML relationships for Green ".

 

Step 3: Create a workspace on your machine

Create a directory named workspace somewhere on your machine in a location that you will remember. It might help to put the workspace directory in a directory named cse115, just like in your account on styx.

 

Step 4: Start Eclipse

There is probably a shortcut to Eclipse on your desktop or in your Start menu after installing Eclipse. Click on it to open Eclipse.

Once you have started Eclipse, you might be prompted for which workspace you'd like to work in. You should select the cse115/workspace directory that you just created. This dialog is reprinted here:

Be sure to check the box "Use as default and don't ask me again", and then click "OK".

Step 5: Import preferences file

Next you need do tell Eclipse a few things about how you want it to behave. This is a one-time process. In other words, once you have successfully carried out these steps you will NOT need to repeat them in lab.

The preferences file is now located in your home directory on styx. You need to download this file to your machine. Open FileZilla and a connection to pollux like described in the directions for using FileZilla. You should see the file cse115.epf in your home directory. Download this file to your local machine. It might be easiest to dowload the file directly to your C:\ drive.

To import the file into Eclipse, you will first need to open the Import dialog. Do this by selecting "Import..." from the "File" menu. It is common practice to abbreviate menu selections that you need to make in instructions like these. For example, we can abbreviate

select "Import..." from the "File" menu
by simply writing "File" -> "Import". This time we'll show the screen shot of the menu item being selected, but from now on we'll simply write menu selections using this abbreviated method. Your teaching assistant can help you if you have trouble locating the correct menu selections.

An "Import" dialog window should appear.

Select the + sign (or the > symbol depending on your OS) and expand the "General" Folder. Note that there is now an option for t "Preferences", as below. Select it and then click "Next".

This opens up an "Import Preferences" dialog window. Browse to the file cse115.epf where you have saved it.

The rest of the options should be OK as they are (they should be as in the screenshot above - if not, make them the same). Click "Finish".

 

Step 6: Seeing the connections to code repositories

If you do not have a tab in the lower portion of your screen that says "CVS Repositories", you should open that View so that you can see what Repositories you have connections to. To do this, select Window -> Show View -> Other. You should then select to expand the entry for CVS and select CVS Repositories and click OK. You will now see a view tab on the bottom of your screen that shows which repositories you have access to:

Step 7: Working on your Project from home

Chances are that you will probably be working on your projects both from your home machine as well as in Baldy 21 throughout the semester. Therefore, you need to not only know how check out from the repository, but also how to transfer your files from one machine to another.

Check out Lab2 project from LabSkeletons repository

Open the LabSkeletons repository (click on the "+" or triangle to the left of its name to "spin" it open). Open "Head", and then a dialog will pop up prompting you for your password. The password here is the same one you type to log into the machine in Baldy 21. Type your password in and then click "OK".

Then the files in the Lab Skeletons Repository will be visible. Select Lab2:

Now right-click, and select "Check out".

In the left-most pane you will now see the Lab 2 project in your workspace. You should expand out the project to see what is inside it.

 

Getting files ready to transfer from your home machine to school machine (or vice versa)

First, you need to export your solution from the Eclipse environment so that you can transfer it.

You should disconnect your project from the CVS repository from which you checked out the lab skeleton (if you have not already done so). To do this, right click on the project name, and select "Team" -> "Disconnect". In the "Confirm Disconnect from CVS" window that pops open select "Also delete the CVS meta information from the file system.", then click "Yes":

Now it is time to package up your completed work to get it ready for submission. Right click on the project name, and select "Export...". An "Export" window will open. Under Java, select "JAR file":

Click "Next>". This brings up a new screen. Make your screen look like the one below:

To pick a name for the file you are exporting to, click the "Browse" button next to the field labelled "JAR file:". Your dialog should now look like this:

Click "Finish".

Now you have a JAR file on your machine (either at home or on styx). You need to transfer this file to the other system using FileZilla.

 

Importing the file into the other system's workspace

OK - so you worked on one system and have now transferred a JAR file to the other system. To get the updates to take effect on that system, you need to import the files to your workspace there.

If this is the first time you are working on this project on the system, you will need to begin by creating a project in your workspace for the system. If you already have a project on your workspace, skip down to here.

To creat a project, right click on the package explorer pane and select New -> Project and the following dialog will appear and you should select Java Project and click Next>

You will get another dialog. Enter the name of the project and click Finish.

A project will now appear in your workspace.

Now, right click on the project and select "Import" and Archive File and select Next:

In the next dialog, Browse to the JAR file you just transferred and it will appear in the "From Archive File" text box: You should click the Select All button so that all of the files in the JAR get imported and then click Finish.

You might be prompted if you want to overwrite files. You should select "Yes" or "Yes to All".

Now the files that you were working on on the other system are available to you. When you are done working on the assignment, you need to export the files to a JAR. You should always make sure that the latest files are on styx as styx is backed up regularly.

If you are ready to submit your work, refer to the instructions below.


Lab Assignment

Before you begin on the actual work for this lab, let us begin by simply running the skeleton the way it is so that you can see what you've got.

Right click on Applet.java in the "Package Explorer" tab. Select "Run As" -> "Java Applet". (Or possibly: Run... and fill in)

You should see a blank AppletViewer window appear:

The window is blank because you have not filled in the definition of the Applet class: there is nothing to show yet! Notice that the AppletViewer window is pretty small. We will need it to be a bit bigger to see all the parts that will eventually appear in our program. Exit the AppletViewer by selecting "Applet" -> "Quit" from the AppletViewer menu (or by closing the window). Next, to make the default size for this AppletViewer window a bit bigger, right-click on Applet.java and select "Run As" -> "Run..." This brings up a window labelled "Run" through which you can manage run configurations.

 

Select the "Parameters" tab and set the width to 450, and the height to 300 so that it looks like the screen below. Click "Apply":

 

If you now click "Run" you will see a large (but still blank) AppletViewer window. Exit from the AppletViewer again ("Applet" -> "Quit").

Now, to get the program to show us what it really can do, all we need to do is to create an instance of the lab2lib.Lab2Program in the constructor of our Applet and run the program again. Feel free to run the program multiple times as its behavior can be different each time. Once you have satisfactorily completed this, you have finished the coding portion of this lab.

Meet your Mentor (CSE 503 students are exempt from this part of the lab)

The non-coding portion of this lab is to attend the first meeting that your mentor is having. The mentors have collected your schedules and will be finding a meeting time that works for them as well as the people in your mentor group. You should go to the meeting and find out what mentoring is all about and what kinds of information you can share as a group. Your mentor will record your attendance at this meeting and your attendance will be a portion of the lab grade for this lab.

Your mentor will be in touch via email or through the course website. If you are having difficulty attending one of the mentor meetings from your recitation, please note the schedules of other mentor meetings. You can attend another mentor's meeting to gain credit for this portion of the lab. If you are having difficulties with this part of the assignment, please contact your instructor.

Note: The first meeting may actually occur after this lab is due for you. You are still required to turn in the coding portion on time. You should then attend the meeting at its scheduled time.


What you hand in

When you are finished, you need to export your solution from the Eclipse environment using the same procedure as before. Make sure you also transfer the file to styx.

Then, you can go to campus and log into a computer in Baldy 21, or you can use PuTTY to get a connect to styx from your current machine.

Once you are on styx, you can use the electronic submission program that corresponds to your recitation. For instance students in section A4 will submit by typing

submit_cse115a4 Lab2.jar
  

at the Unix prompt.


Due dates

You have one week from the meeting of your lab to submit your solution. For example, if your recitation meets on Tuesday, January 30th then you must submit the lab by 11:59 pm on Monday, February 5 th. The due dates are summarized in the table below. You are always welcome to submit early. If you submit more than once, the later submission will simply overwrite the previous one.

To check that your lab was submitted, you can always refer back to the Submit Inspector on the Resources page of the website. After you have entered your user name, your submissions will be shown. Clicking on the name of a file that is a zip file will show you the contents of the zip file so you can verify that you indeed zipped up all the correct files.

Date of lab Due date for electronic submission
Tuesday, January 30 Monday, February 5
Wednesday, January 31 Tuesday, February 6
Thursday, February 1 Wednesday, February 7
Friday, February 2 Thursday, February 8

 

CSE 115 - Spring 2007 - Footer

 

 
Last modified: Mon Jan 29 17:19:31 2007
© Adrienne Decker