Lab 01

PLEASE NOTE: All lab exercises are due the following Sunday by 11:30am.
  1. Ensuring you have a cs125 directory
  2. What you need to know
  3. Logging on to Unix and changing your password
  4. Checking your e-mail
  5. Running a simple program
  6. Downloading a zip file
  7. Opening and compiling/running a file in DrJava
  8. Request lab solutions

Ensuring you have a cs125 directory

As soon as you first log in to Mac OS in the lab, it is best to ensure that you have a cs125 directory. To do this, click the 'Finder' icon as shown in the picture below.

In the new window, ensure that your username is selected on the left. On the right you will see a list of all your student.cs files. Look for a CS125 directory as shown in the following picture. Once you have found your CS125 directory, move on to the next section entitled Logging on to Unix and changing your password.

If you did not find the directory, it is easy to create one. Click 'File' from the top menu bar and then 'New Folder'. Name the folder 'CS125'. Two images are provided below demonstrating this. If after creating the directory you accidentally click somewhere before typing in the new name of the folder, you can easily 'single click' the name of the folder and wait a few seconds. You will then be able to rename it again.

What you need to know

This lab is short since your main job is to become familiar with Mac OS X. Therefore we have put together a guide that you should read before proceeding. Proceeding without reading the guide and having little or no Mac experience will cause you to struggle not only with the rest of this lab, but also all the remaining labs and assignments.

Logging on to Unix and changing your password

The next thing you need to do is log on to Unix and change your student password if you have not done so already. Please note that Mac and Nexus are different and changing your Nexus password will not affect your Mac password. You NEED to change your Mac password and you need to change it through Unix.

Instructions for logging on to Unix under Windows are available under the Resources section. However, if you are in the Mac lab:

First, click the 'X11' icon as pictured on the right. Once the X11 window opens you connect to a student.cs server and login to Unix.
Next click on the Applications menu as shown on the right. You may or may not be asked for a password. Then choose "xterm on cpuXX" where XX is an even number. (It doesn't matter which).

Once logged in to student.cs UNIX, your screen should look something like this.

To change your password,

type passwd. You will be prompted for your old password and then required to enter a new password. The password that you choose must follow the following conditions:

  1. the password must be 7 or 8 characters
  2. it must contain 3 of the following types of characters:
    1. Uppercase letters
    2. Lowercase letters
    3. Numbers
    4. Punctuation
  3. it may not contain more than 3 consecutive letters
  4. it may not contain more than 2 consecutive digits

The screenshot provided below shows an example of changing your password.
NOTE: Your password will NOT be displayed as you type them for security purposes!

If you are interested in exploring Unix further, you can try these handy commands.

Checking Your e-mail *IMPORTANT IF YOU WANT LAB SOLUTIONS*

From time to time the course staff will send you e-mails with regards to assignments, exams, labs, and administrative business. It is important that you know how to check your UW e-mail and do it on a regular basis. Follow these e-mail instructions for step-by-step instructions on how to check your e-mail.

Running a simple program

The next part of this lab will introduce you to the idea of a development environment. Load DrJava by clicking the DrJava icon located on the dock bar. A picture of the icon is shown below.

If you are at home, you can follow these instructions to download and install DrJava on your home computer.

Once DrJava has opened you should see a large white area on the right side of the screen where you can type text. This is like one big word processor, except that instead of writing documents, you will write code. Here is where you will write your first program. Type in the following program replacing yourname with your full name. Do not worry if you do not understand any of it yet. You will after the next few weeks.

public class MyFirstProgram 
{
  public static void main(String[] args) 
  {
    String name = "<yourname>";
    System.out.println("Hello World");
    System.out.println("My name is " + name);
  }  
}

A picture of what DrJava should look like is shown below. The sample code has also already been typed in.

Once finished, click the Compile button located near the top of the screen. You might need to save your program first. If so, make sure you save it to your home directory, specifically your CS125 directory. Please note that you need to save the file so that it is the same name as the class. In this case our class name is MyFirstProgram. So your program needs to be saved as MyFirstProgram.java. After compiling, look at the bottom white area in DrJava. If you see anything in yellow or the word 'Error', then you have a problem. Look at what line the error is on (it will say the line number to right right of the error). Make sure you copied out every line exactly as shown above. Once you have fixed the error or if you had no error in the first place then you can click the Run button.

In the white space at the bottom (same place you got your error output) you will see the output of your program. Now copy the entire contents of this window into the box below and submit the results by clicking on the submit button. You will be asked for a username and password. This is your QUEST username and password.


Downloading a zip file

For each lab after this one, the first thing you will do is download the files needed for that week's exercises. Here are the instructions on how to do that.

  1. First, we are going to change the directory that Firefox saves to. Open up Firefox with the icon on the dock.
  2. Click on the word Firefox in the menu bar. (It should be right next to the little apple on the top left of your screen. If not, click on the Firefox window that is loaded, and then it should appear.) Choose Preferences, seen below.

  3. Navigate to the Downloads tab by clicking the corresponding button, and you should see this, below:

  4. Finally, click on Browse, and click on your username on the left menu bar. You should see a cs125 folder in your home directory. Click on that and click "Choose".

  5. There is one java file contained in a file called L01.zip. The .zip extension says this is a “zipped” archive. That is, it may contain a number of files that have been gathered together into one to make downloading easier and faster.

    Click here to begin downloading the file. A dialog box similar to the one below should appear. Select the "Save to Disk" option as shown below.

  6. After saving the zip file, you can open up 'Finder' from the dock bar. Make sure your username is selected in the left toolbar. Locate the file in the right part of the window and double click on the icon. This will automatically open the zip file and extract it to your home directory's cs125 directory. In the cs125 directory, it will place the files in the L01 directory to show this is lab 1. You can check this out by double clicking the 'cs125' folder and then double clicking the 'L01' folder. This should contain a file called TestFile.java.

  7. If you're doing this at home on a Windows machine you will need an application such as WinZip or some equivalent program. WinZip is a file compression and archival tool.

Opening and compiling/running a file in DrJava

  1. You can now test this file by opening it in DrJava and running it. To open DrJava, find the icon on the dock bar and click it. Be sure to read the points below first.

  2. If you are at home, you can follow these instructions to download and install DrJava on your home computer.

  3. Once Dr. Java is loaded you should see something similar to the screen below:

    Dr. Java Welcome Screen

  4. After opening DrJava, click the Open button at the top and navigate to where your files are in your home directory. Select the one you want and then click open. In our case we will want to open TestFile.java in the 'L01' folder which should be located in the 'cs125' folder.

  5. After opening your file, you should see code on the screen. This area is where you will do most of your coding for assignments. To run this code you must first compile it (translate the code to a language the computer understands). To do this click the Compile button in DrJava's tool bar. Any compile problems will appear in the bottom dialog box. These are called "compile time errors" and must be resolved before you can run your code.

  6. If it compiles successfully without error then you may click Tools->Run Document's Main Method or the run button to run the program. Any output will appear in the output pane. If you have any questions or problems, now is the time to ask as these steps are crucial to being able to do assignments. This is how you should compile and run your programs that you make in assignment 1.

Please copy all information that is output in the bottom window by the program when it is run, paste this in the area below and click submit. Please note this may require your QUEST username and password.


NOTE: You must hit "Submit" on every box. It is not enough to hit "Submit" on the last textbox. You must hit "Submit" on every box (that is, you will hit "Submit" multiple times on each lab).

Ensuring your Lab exercise has been submitted successfully

If you want to check if your lab submissions were successful, or if your assignments were submitted successfully, click on Student Admin on the left menu, and then Request Lab and Assignment Information. Choose the lab or assignment number you want to view, and then press the Electronic Submission Information button. Enter your QUEST Username and Password at the prompt. The date of your submission and the size of your submitted file will now be displayed.

You are now done lab 1.

Request lab solutions

If you request solutions for this lab you will be sent an email that contains your answers as well as the expected answers. The email will be sent out to all interested students once the deadline for completing the exercises has passed for all students in the course (the mailing will usually occur Monday mornings). Note that you will only receive answers for submissions you have made (i.e., if you don't submit an answer, a solution will not be sent).