Lab 0: Meet the lab and its tools

Due at 6PM on Sunday February 5.

Assignment Description

This lab is intended to be a bit of a review of the things that you've done in CS 150 and to introduce you to some new tools. At the end of this lab you should be able to:

  1. Get yourself into the labs after hours without climbing through the windows,
  2. Log in to the lab machines,
  3. Use eclipse and some of its bells n' whistles,
  4. Remember some of the stuff you learned in 150.

NOTE: This lab exists outside of the usual late deadlines. You should be sure to do Part 5 on time (sending me an email), but if you run into problems you can get help with the rest of it during the lab times next week without expending one of your late days.

Part 1 - Getting started

Lab access, computer accounts

If you weren't registered for a CS class at the start of the semester, you will need to go and see Jackie Fortino in King 223 about getting building access for the semester. You should do this now, before you forget!

If you don't have a CS account, see Chris Mohler in the OCTET office (King 125) about getting one.

Go to one of the CS computer labs and log in to a computer. The labs are in King 201 and King 135. You should have gotten the door code from your CS professor on the first day of class. For the most part we will use room 201 unless the class becomes too large.

Create a directory for this course and lab

Once you have logged in, make yourself a directory to put your class work in. Using a Terminal application:

% cd
% mkdir cs151
% cd cs151
% mkdir lab0
% cd lab0

You should do this for each lab, not only because it organizes your files, but also because it causes less problems with handin. And you don't want any problems with handin.

Part 2 - Eclipse

Now you should start Eclipse. This is a Java IDE (Integrated Development Environment) that is used world-wide. It has a number of very useful features including automatic compilation, error detection, built-in debugger, autocomplete, and many other features.

Eclipse is available for free for your home machine, should you want some alone-time with it. Just go to the Eclipse website for download.

Start eclipse

Just run it from the command line.

% eclipse &

Alternatively, choose it from the graphical Development menu.

You should just accept the default for workspace. (Usually ~/workspace/) Please do not select your csci151 folder as your default workspace. It'll take a bit to start up.

Do tutorial

From the Eclipse Welcome page, click Tutorials > Create a Hello World Application. Follow the instructions to make your very first eclipse Java program. Good times.

Customize Eclipse preferences

Until you get more familiar with eclipse and figure things out on your own, please make the following changes to your preferences to make life easier. Start by selecting the menu Window   >   Preferences (On a Mac, it is located in Eclipse   >   Preferences.

Set preferences

First, let's deal with auto-completion and cursors. Click on the triangles in front of "Java", "Editor" and click on "Typing".

Notice that it will automatically insert closing braces, quotes, and the like by default. I recommend that you keep these enabled. It will take a little getting used to, but prevents annoying little bugs.

The second section "automatically insert at correct position" has things that I really like to enable. When you type either ; or a brace, it'll jump to the right spot for it most of the time. It's pretty nifty, try it out!

Fixing output to be more sane

By default, Eclipse uses tabs for indentation. However, it displays them as being only 4 spaces, when most other things will display them as 8. A minor detail, but changing this will make things much more readable outside of Eclipse. The easiest way is to change the preferences "Java", "Code Style", "Formatter" and then select "Java conventions" as the Active profile. If you change only one setting, make it this one!

Code Style settings screen

You can also get Eclipse to reformat your code when you are working on it in a number of ways. You can highlight a section of text and then hit "ctrl-I" or use the menu "Source", "Correct Indentation". You can also use the "Source", "Format" command to make similar changes. You can also have it automatically reformat your code each time you save. Go to "Java", "Editor", "Save Actions" and check the box marked "Perform the selected actions on save". You can have just reformat the sections of code you have been working on, or you can have it take care of the entire file.


If you take advantage of the auto-Javadoc comments, you'll probably want to also change the settings under "Java", "Code style", "Code Templates", "Comments", "Overriding methods" to match "methods". (Just copy and paste the Pattern window contents from "Methods" to "Overriding methods".)

Change the default build path

In recent versions, Eclipse likes to put the *.class files in a different folder than your *.java files. However, this makes things a bit harder to go between eclipse and a normal editor. Change the preferences by selecting "Java" and "Build Path" and change the value of 'source and output folder' radio button to be "Project" instead of "Folder". Do not change the value of Source folder from src or Output folder from bin -- this is the radio button only. If you change only two settings, do this one too!

Build Path settings screen

do some editing

While you are working on stuff, you'll probably find that there are lots of functions you might want to use via the pull down menus. Note that the keyboard shortcuts are listed on the right hand side. Learning to use them will speed up your work.

As a reference guide for some such shortcuts and nifty things, I'll refer you back to the eclipse tutorial, and this list here:

Part 3 - Doing "real work" in Eclipse

Create project

Now we should create a project in our lab0 folder like you'll be doing in many of the labs.

  1. Select "File" > "New" > "Java Project"
  2. Call it "Hello 151" (or "lab0" or whatever you want)
  3. uncheck the box for "use default location"
  4. Use the "Browse" button to select the lab0 folder you created earlier
  5. Now just select "Finish"

If you want, you can close the Task List and Outline panes on the right side. We won't be using them for this.

Now let's create a class that will tell the user a little bit about yourself.

  1. Select "File" > "New" > "Class"
  2. Don't change the project or source folder
  3. Set the Name of class to be Hello151
  4. Check the box that will create the main method stub
  5. Now select "Finish"

You should now see in the Package Explorer window. If you do an ls on the command line in your lab0 folder, you'll see that there is both and Hello151.class in this folder. Eclipse compiles as you work!


The file should be open in the editor. If not, just double click on it in the Package Explorer window. Let's add some comments to the top of the file.

  1. Go to the top of the file and start a Javadoc comment. Recall they begin with /**
  2. Put in a short description of what this file is supposed to do. In this case, you are going to introduce yourself to the graders.
  3. On another line, but still in the comment block, start a line with @author followed by your name
  4. Close the comment block with a */. It is likely that eclipse has already done this for you.

Run your program

Just in case you've not actually tried to run your program, now would be a great time to check that it works. Here's a line you can add to the main method that will give you some output

    System.out.println("When I graduate, I will donate 10% of my salary to the CS department.");

You can run it in Eclipse by just selecting "Run", "Run" from the pull-down menus. Or right-click and select "Run As", "Java Application".

If you want to try running your program from the command line then you should

  1. Go to a Terminal window
  2. Type "cd ~/cs151/lab0" (this takes you to your lab0 folder -- '~' is a shortcut for your home folder)
  3. Run the program by typing java Hello151

Note that if that didn't work, and you see that you have bin and src folders in your 151/lab0 folder, you missed one of the important steps above.

Share with the graders

Now let's add some print statements to introduce yourself to the graders. Inside the main() method, add in a number of System.out.println messages that will share:

  1. Your name as you want to be called
  2. Your CS username
  3. Your year/major (if known)
  4. Something you think is awesome about Oberlin

Get on with your life

If you've made it this far, and actually changed preferences and done the steps I listed above, that's enough Java programming for this week.

Part 4 - Lab tools

Running Java

For this class, we'll be exercising more than the usual amount of memory in Java programs. You will become familiar with the -X family of arguments to use with Java.

% java -Xmx1g MyProg     # use up to 1 gigabyte of memory
% java -Xmx500m MyProg   # use up to 500 megabytes of memory

Last semester this wasn't needed on lab machines, but was on your own laptops.


The CS server will be making periodic backups of your files for you. You can access these backups in the folder


This is an exact copy of your files at the time the snapshot was made. It'll be useful if you accidentally delete something in lab. Currently only the daily snapshots are working (taken at midnight each night), but hopefully we'll have some that are more frequent as the semester progresses.

handin / lshand

handin is the right way to submit your work in this class. If you talk to other students, they might tell you about a web based version of handin. Please don't use this as it is unsupported and has resulted in more than one student submission being discarded last semester. Run away from the fish!

I'll probably give you instructions on how to use handin as shown below as part of your instructions each week, but I suspect you've got the hang of it by now if this is your second CS class.

Also, always use lshand to verify that your submission was received. If it does not show you your latest submission, then we don't have it.

Should handin be broken at the deadline, email us ASAP and stop editing stuff in your lab directory (or email the files in lieu of a submission).

Part 5 - Last things

Be sure to get grade reports

You should also add a rule into your OCMail so that mail from the grader doesn't go into your Spam folder. (This seems to happen randomly throughout the semester.)

  1. Go to and log in to your Oberlin email.
  2. Do a search for
  3. After you've searched, on the right side of the search box, you should hit the gray downward facing triangle, and then select "Create filter with this search" in the bottom right.
  4. Check the box for the line "Never send it to Spam"
  5. Click on "Create Filter" in the blue button below, and you should be all set.


Look through your source files and be sure you've included you name at the top of all of them. If there are any known problems or incomplete features, document that also at the top of the file. If you adhered to the honor code in this assignment, add the following statement as a comment at the top of your main java file.

I have adhered to the Honor Code in this assignment.


You now just need to electronically handin all your files. Quit Eclipse and delete the class files. (Otherwise those will be handed in as well!)

% cd          # changes to your home directory
% cd cs151    # goes to your cs151 folder
% handin      # starts the handin program
                        # class is 151
                        # assignment is 0
                        # file/directory is lab0

% lshand      # should show that you've handed in something

You can also specify the options to handin from the command line

% cd ~/cs151                 # goes to your cs151 folder
% handin -c 151 -a 0 lab0

That's it! You've completed your zeroeth lab. Be sure to logout when you are done (icon is to the left of the terminal and globe icons).


Be sure that you have

  1. Accepted the default workspace
  2. Changed settings to use "Java Conventions"
  3. Changed the settings for "Build Path"
  4. Added the filter for your OCMail account

Last Modified: January 2017 Bob Geitz, based on material from Robert Hoyle, Benjamin Kuperman and Alexa Sharp