Computer Science 211
Data Structures

Mount Holyoke College
Fall 2009

Java and Unix on the Kendade 307 Macs

This is the repository for information about how to do the things you need to do to use the Macs in Kendade 307 to complete your lab assignments for Data Structures.

Mac Basics

Running Java Programs at the Command Line

Running Java Programs in Eclipse

Creating a "tar" File for Submission

When we have multiple files to submit for an assignment, you will be asked to submit a single "tar file" that contains all of the required files. A tar file is like a "Zip file" from the Windows world.

We create a tar file using the tar utility at the Unix command line in a terminal window (such as the Mac's Terminal or the shell you get when you use secure shell to connect to babyred). Historically, the tar program was used to create tape archives, hence the name.

Until you get the hang of it, you'll want to be extra careful using tar. Incorrect usage could wind up corrupting your files. So I recommend the following steps:

  1. Create a new, temporary directory/folder. For example:
    mkdir ~/lab2submit
  2. Copy all of the files you wish to include in your tar file to that directory. For example, to include all of your Java source code and a file lab2.txt from the directory where you developed your programs (in this case, ~/cs211/lab2):
    cd ~/cs211/lab2
    cp *.java lab2.txt ~/lab2submit
  3. Change directory into your temporary directory and create your tar file. For example, this creates lab2.tar:
    cd ~/lab2submit
    tar cvf lab2.tar *.java lab2.txt

    You should see a message from tar listing the files that are being added to your archive.

    The cvf parameter seems cryptic (and, yes, it is) but you can remember it if you know what it stands for: c is for create, v indicates a verbose mode (and is optional), and f says to create the file speficified by the next command-line parameter, lab2.tar.

    In any case, you should now have a tar file lab2.tar ready to send as an email attachment to submit your work.

  4.'s always a good idea to make sure the tar file you have created does in fact include the files you think it includes..

    First, you can list the contents of your tar file to make sure it has the files you expect. For example:

    tar tvf lab2.tar

    But better yet, you can extract your tar file into an empty directory and make sure the files there are the ones you expect and that their contents are correct. For example:

    mkdir ~/lab2test
    cd ~/lab2test
    tar xvf ~/lab2submit/lab2.tar

    Here, the x indicates extract. You should then have the files from the tar file in your test directory.

  5. If all is well, remove your temporary folders and their contents to keep your account tidy.