ICS 21 / CSE 21 Summer 2012
Lab 0: Orientation to the Lab


Introduction

Before embarking on your first lab assignment, there are some things that you'll need to know how to do, in order to get yourself oriented to our labs and generally being a student in the Bren School of ICS and UCI. Be sure to read all of this orientation section. Practice the parts that are new to you, or for which you need review. Do the activities needed for the course (e.g., activating your computer accounts) that you've not yet done.

Pay attention to the details given here, as common computing tools or activities are often somewhat different in our labs than, say, on your home computer. For example, you'll want to know how to access your @uci.edu email, even if you normally use something else, since all course-related emails will be sent to that address.


Read documents detailing computer use and academic honesty policies

Each of you must read a few documents stored on the Web that address ethical use of computing resources and academic honesty issues. (You may also be asked to read some of these documents in the course of activating computer accounts.) We require you to read these documents because, unfortunately, a few students in the past have abused their computer privileges or acted dishonestly and claimed ignorance of the wrongness of their actions. Note that remaining or enrolling in this course binds you to abiding by these rules.

These documents cover several important policies about academic honesty that apply to you.


Activate your UCInetID and ICS accounts

UCI provides all its students with basic computing, including electronic mail and Internet services, via a “UCInetID” computer account. All ICS 21 or CSE 21 students need this account: if you have not yet activated your UCInetID, go to the UCInetID Services page, click on the appropriate link under UCInetID Activation and follow the instructions. Be sure to have your student ID and social security number handy; you’ll need them to complete the activation process.

You will also need an ICS computer account to use the computers in the lab rooms. If you are already enrolled in the course, or a major in the Bren School, the School has already created your account. If you want to add the class (and are not a Bren School major), your account will be created a day or two after you enroll.

You need to activate your ICS account to use it; bring your UCI student ID card (and yourself!) to the lab attendant in ICS 364. Your ID will be verified; you then take an on-the-computer quiz about the rules regarding use of ICS computer resources and provide a password. Your account is now ready for use. For details on activating ICS accounts, see the Instructions for Account Activation Web page.

Your ICS account also provides you access to a Unix account that has the same login name and password. We won't use that account for this class, but it is a good place to store a backup of your computer work. The storage associated with your Unix account will be available as drive H: when you're logged into one of the ICS lab machines. Note, though, that the amount of storage available is limited, so you might well be better off using USB storage or your own laptop to store backups of your work.

Explicit instructions for activating an ICS account are provided at the ICS Labs web site.


About the ICS lab computers and network

(It's possible that some particulars of the network will change after the quarter begins. If any of those changes affect the instructions given here, we'll announce them either in lecture or lab sections.)

Each first-floor ICS lab room has from 30 to 45 workstations forming a local area network (or LAN); Windows 7 is the operating system for each station. Each machine has more than enough horsepower for the work we will be doing in this course. There are also shared printers and several shared disk drives (called file servers).

All of the machines have available USB ports that can accept memory sticks and portable hard drives, among other devices. Each machine also has a large local hard disk, where we store software for your use and where you can temporarily store your work — once you leave lab, you must remove all your work (and only your work, nothing else) from the hard drive.

Through your station you can also access the class file server and use the shared printers.


Logging in and out of the ICS lab workstations

Logging in

Unlike some other local area networks, Windows requires you to log on to the ICS network, even if you don't plan to use network resources.

When you sit down at a lab station, it could be in a number of states, depending on whether the last user of the machine logged off (properly) or shut the machine down, or whether the computer entered a power-saving (sleep) state. So, ICS 21 Help Center staff will instruct students in how to log in from various states as part of the first day's orientation to lab and the class. Of course, do ask questions as needed!

About your password

You will want to change your password whenever you think it has been compromised. To do so, hold down Ctrl and Alt and hit Delete. Choose Change Password..., fill in the old password and new password (twice) as prompted, and then press Enter to make the change. If your password change is accepted, you'll get a message to that effect; if not, you'll be told that as well; read the message, dismiss it, and try changing your password again. Keep at it until you enter an accepted password.

Remember your password! No one can look up your password — it's encrypted. So, if you forget your password, you will have to send email to helpdesk@ics.uci.edu to request that it be set to a new one (that you've given in the message), wait a day or two for the change to occur, and then log in and change your password so that (again) no one knows what it is.

Logging out

When you are done using the computer:


Printing

We do not require printouts of any kind in this class, but you may find you wish to print some of the course materials, such as all or part of the Lab Manual, for easier reference.

ICS and OIT computer labs use the PayPrint system to provide printing services. Instructions for using PayPrint in ICS labs is at Printing in the Labs; the PayPrint system in NACS labs works the same way. Note that you have to purchase a PayPrint card to use this facility.

Since the PayPrint system provides you access to printers in labs across campus, be sure to print to the station you intend, so that your output will go where you expect. It's usually best to send your printout to a station in the room you're in.


Email

The easiest way to access your @uci.edu email from the ICS labs is via a web-based interface called WebMail. Just go to the WebMail page, log in with your UCInetID and password, and your email appears. To learn how to use it, just click on the Help link near the top center of the main mail page, then the Table of Contents link in the window that appears, which will take you to WebMail's user documentation.


Using Eclipse

What's Eclipse?

Eclipse is an integrated development environment (IDE), which combines a text editor, a compiler, a virtual machine, and a number of additional tools into one application. Eclipse was not designed for educational purposes; it's an industrial-strength tool that is much more complex and full-featured than we'll need in this course. However, it has many benefits in an educational context, such as these:

When using a large, complex tool for the first time, the tricky part is not allowing yourself to become lost in all of the details and options that it presents to you. It turns out that you don't have to know very much about Eclipse to use it effectively in this course; this lab assignment is intended to equip you with most of the knowledge you'll need for the duration of the quarter. Once in a while, a new Eclipse skill will be required; when one is needed, I'll introduce the steps.

The following is a screenshot of Eclipse in action:

Eclipse screenshot

The window is separated into a few major areas that you'll find useful:

The purpose of a workspace

One of the helpful features of Eclipse is how it helps you to organize your work, on one project or many, easily. It also gives you the ability to tweak a wide variety of settings, such as the version of Java to use to compile your programs, the fonts and colors displayed in the editor, the style of the code that Eclipse generates for you, and so on. A workspace is the repository for all of the files that make up your projects and all of your settings.

A workspace is stored on your hard drive within a single folder. When you start Eclipse, you select the workspace (the folder) that you'd like to use. I suggest using a single workspace for all of your work this quarter, as it will give you easy access to all of your previous work, as well as maintain your settings from one project to the next.

Downloading and installing our workspace for this course

Eclipse provides a large set of options that allow you to configure it. When you're using it for the first time, though, it's hard to know which options to change and what you should change them to. Unfortunately, the default settings aren't entirely appropriate for us in this course. Additionally, personal preferences tend to differ, which can sometimes make it difficult for a pair to work together productively.

To keep things straightforward for us this quarter, we'll all use the same initial workspace. I've created an empty workspace, with settings appropriate for your use this quarter; these settings will match the settings used by your TA when grading your work. The "official" workspace for our course is available at the link below.

The workspace is provided in zip format; to use it, unzip it to a folder in a place you'll be able to find again. A good place to put it when working in the ICS labs is on a USB drive, so that it will be available to you regardless of which machine you're logged into, but you should be sure to keep a backup in case you lose the original.

Starting Eclipse

To run Eclipse in the ICS labs, go to the Start menu, then find and click the shortcut titled Eclipse. When you first start Eclipse, it will ask you what workspace you want to use. Rather than accepting the default, type the complete path to the folder containing the workspace you downloaded and set up in the previous section (e.g., H:\21Workspace). This will cause Eclipse to start with your workspace loaded, already configured and ready for you to work.

(It's possible that you will not have been given a chance to specify what workspace you want; it will sometimes be the case that Eclipse has been previously configured on the lab machine by another student so that it won't ask. If you're not asked, but Eclipse instead starts up, go to the File menu and select Switch Workspace... and then Other..., then choose your workspace.)

Creating a new project

When you first start Eclipse in your new workspace, you'll find that there is nothing listed in "Package Explorer." Eclipse organizes your files into projects, with each project representing one program. In order to proceed with this assignment (and subsequent programming assignments), you'll need to first create a new project within your workspace, which will contain all of the .java files (and sometimes other files) that make up your program.

To create a new project, go to the File menu, select New, then Java Project. You'll now be presented with a dialog that asks you to name your project, and also make some other choices.

Once you've made these selections, click Finish.

You should see a folder called Lab0 listed in the "Package Explorer." This folder represents your new project.

Importing Java code into a project

To give you a program to work with, I've written a short program that plays the "guess a number" game, where the computer chooses a number at random, then asks the user to guess what it is, providing hints along the way. The program is contained within the following three files:

To begin with, save these three files somewhere on your machine's hard drive, but not within your Eclipse workspace.

The next step is to import the code into the Lab0 project in your workspace. This turns out to be relatively simple to do. Remember that, when you started Eclipse, you selected the folder that contains your workspace (e.g., F:\21Workspace). A workspace is entirely self-contained within that folder, including all of your settings, preferences, as well as all of the files in each project within the workspace. Go to your computer's Start menu and choose Run.... In the ensuing dialog, type the complete path to your workspace folder (e.g., F:\21Workspace) and click OK. This will open your workspace folder so that you can explore it.

Notice that, within your workspace folder, there is a folder called Lab0. This corresponds to the Lab0 project that you created earlier. (There is also a folder called .metadata, which contains all of your preferences and settings.) Within the Lab0 folder, you'll find a folder called src. The src folder is intended to contain your .java files. (There is also a bin folder, which is intended to contain the compiled versions of your .java files, called .class files.)

Find the three .java files that you downloaded and drag them into the src folder inside of the Lab0 folder within your workspace. Then, in Eclipse, go to the Package Explorer area, right-click on the Lab0 project, and select "Refresh" from the menu. Voila! The three .java files are now part of your project!

Running a Java program from within Eclipse

A Java program is executed by specifying its "main class," the class that contains a special method called main with this signature. (We'll talk more about this in lecture.)

    public static void main(String[] args)

In the case of this program, the main class is GuessNumberUserInterface. To execute the program, then, we can right-click GuessNumberUserInterface.java in the Package Explorer, then select Run As..., then Java Application.

This program performs all of its input and output via the console. When you compile and run a program from the command line, the command prompt window also acts as the program's console. But when you run a program from within Eclipse, it's not directly obvious where the console should be.

Look at the area of the Eclipse window where the "Problems" (error messages, warnings) are listed. There are other "tabs" available in the same area as the Problems tab. One of them is titled "Console". Click it. There's your console! Input and output can be handled within that window, in the same way that it was handled in the command prompt window in your previous coursework.

The "Console" tab gives you a valuable clue about whether a program is still running or has completed. For example, consider the following screenshot:

Notice the red, square-shaped button that's lit up; this button can be used to stop a running program. It can also tell you whether a program is still running, because it will only be active if the program is still in progress. When a program has stopped, you'll find that the square-shaped "stop" button is no longer active, as in the screenshot below:

It's generally a good idea to dismiss the console output window when you're done with it by clicking the dark gray "X" button next to the "stop" button within the console area. (Don't click the "X" button next to the word "Console," though; that'll get rid of the Console tab from your user interface.) If there is more than one console output window within that area, you can click the button with two X's instead to dismiss all of them. (If you don't dismiss consoles when you're done with them, you'll find sometimes that multiple old versions of your program will still be running, which can be confusing.)

Viewing and editing your program's source code

You can view your program's source code by double-clicking on one of the files listed in "Package Explorer." Try double-clicking GuessNumberUserInterface.java. Don't worry if you don't understand how the program works; we haven't learned anything about Java yet!

You can edit the code roughly as you would in a word processor. There are significant ways that editing code is different from editing prose in a word processor, but we'll learn more about them another time.


Conclusion

If you've gotten this far, you're ready to embark on your first lab assignment. Nice work!