Homework Submission

Handwritten answers to on non-programming problems should be submitted in class on the due date, at the beginning of class, unless prior alternate arrangements are made. If you prefer to type your answers, please make sure the result uses the proper symbolic notation for relational algebra operators and other constructs. Illegible or hard to read submissions, whether handwritten on typed, are likely to be returned without grading, for zero credit. Answers to programming problems should be submitted electronically, using the packaging and submission procedure outlined below.

Packaging Each package you submit should include a README file and a Makefile (at the top level of the subdirectory described later). The README file is a plain text, ASCII file (not a word-processing file) that includes a brief description of your submission, compilation instructions, and any special instructions or other information relevant to your submission. At the very least, it should include information identifying the submission and its author. The Makefile is used by the program make to determine how to build object files and other derived files from source files. (For more information, type man make at a shell prompt.) A very simple Makefile, suitable for typical Java submissions, appears in Figure 2. You may need to edit it to suit your purposes. You may find copies of this and other files in the Sample Code section on page §.


CLASSPATH=.  
 
default: all  
 
all:  
        @javac *.java  
 
clean:  
        @find ./ \( -name "*~" -o -name "*.class" \) -exec rm ’{}’ \;


Figure 2: A simple Makefile.

For most of the programming assignments, we will use the jar archiving tool that is part of most Java environments (such as Sun’s JDK). The following directions for creating a jar package assume a Unix-based operating system but you may use them on Windows systems by replacing forward slashes (/) with backslashes (\) in the paths.

Each submission should consist of a single jar archive file. You should generate a jar archive called M-hwX-N.jar, replacing M with your last-name, X with a two-digit homework number, and N with an arbitrary 4-digit integer (e.g., Doe-hw01-4242.jar).

The jar file should contain a single subdirectory whose name is obtained by excluding the .jar suffix from the name of the jar file (e.g., Doe-hw01-4242). In turn, this directory should contain the source files, README, and Makefile of your submission. For example, the Doe-hw01-4242 directory may contain the following.

Makefile  
README  
Test.java  
Driver.java

The jar file should not contain any non-source files, such as object code, .class files, and binary executables.

While various IDEs, such as Dr. Java, have built-in jar creation functionality, please use the command line jar tool to create the jar files, since it is simpler and more consistent across platforms. In particular, many IDEs produce, by default, jar files that contain either only .class files or both .class and .java files, without a Makefile or README file, and are thus unsuitable.

Assuming that you have created a directory Doe-hw01-4242 as a subdirectory of the working directory, and that this directory contains the necessary submission files (and no others), you may create a suitable jar file using:

jar -cvf Doe-hw01-4242.jar Doe-hw01-4242

The resulting jar file, Doe-hw01-4242.jar, will include a Manifest file called MANIFEST.MF. A manifest file describes the contents of a jar file. The default manifest is fine for most purposes, but in the future you may wish to to specify an alternate manifest file. More information about creating manifests and jar files can be found at http://java.sun.com/docs/books/tutorial/deployment/jar/build.html.

Testing procedure: We will use a procedure similar to the following to set up your submission for grading using the jar file you submit. Please test carefully that the following procedure works with the jar file you plan to submit. You should test your work in a temporary directory, not the directory containing your code or other material. Begin by creating a temporary directory for testing as a subdirectory of your home directory on gandalf, and making it the working directory:

cd  
mkdir testdir  
cd testdir

Copy your jar file to the newly created directory. For example, if your jar file resides in a subdirectory hw01 of your home directory, type

cp ~/hw01/Doe-hw01-4242.jar .

Now extract the jar file by typing

jar -xvf Doe-hw01-4242.jar

The above command should result in the creation of a directory Doe-hw01-4242 as a subdirectory of the current working directory, which is  /tmp/testdir in our case. Now you should be able to change to the newly created directory by typing

cd Doe-hw01-4242

Typing ls should display the contents of the newly created directory. Typically, these contents include Java source files (*.java), a Makefile, and a README file. Please make sure there are no class files, object files, or other compilation products in the directory at this point. (Your submission should contain only source files.) Finally, typing

make

should result in the complete compilation of your program. Using the sample Makefile of Figure 2, typing

make clean

will remove any class files that the compilation creates.

Submission Once you have created a jar file as described above, you should upload it using anonymous FTP (anonymous as the user name and your email address as the password) to the FTP server cs.maine.edu in directory /incoming/cs/cos226/. (Detailed FTP instructions appear below.) If you need to upload an updated version of your submission for any reason, you may repeat the above using a different four-digit integer in the file name. (If you try using the same file name as your earlier submission, the upload will likely fail.) You will not be able to list the FTP upload directory (standard security setup), so pay attention to the diagnostic messages from your FTP program. If the messages indicate success, your file will have been uploaded. Be sure to use the binary transfer mode when transferring binary files (including jar files) using ftp. Otherwise your files will be corrupted.

You must upload the file before you submit your hard-copy homework. Write down the name and size (in bytes) of the file you submitted near your name on your hardcopy submission for the non-programming problems.

FTP on Unix-based systems: On your local machine (laptop, home computer, etc.), set the working directory to directory containing your jar file, which we will call Doe-hw01-4242.jar below. Then type

ftp cs.umaine.edu

at the shell prompt. The rest of the commands below are to be issued from within the ftp program, at various prompts. You should first be prompted for a user name, when you should type

anonymous

Next, you should be prompted for a password, when you should type your email address, for example,

foo@bar.baz.net

You should ensure that the file transfer is in binary and passive modes by typing

binary  
passive

Set the working directory on the server side to the submission directory by typing

cd /incoming/cs/cos226

Now upload your file by typing

put Doe-hw01-4242.jar

substituting your own file name for Doe-hw01-4242.jar. Finally, exit the ftp program using

quit

which should return you to the shell prompt. As with most Unix commands, you can find out more about ftp by typing man ftp at a shell prompt. If you wish to transfer files to and from your user account on gandalf, you should transfer them over a secure connection. Use the scp program for this purpose. For details, type man scp at a shell prompt. The graphical tool gftp may also be useful.

FTP on Windows systems: You may use the ftp client FileZilla, which is available at http://sourceforge.net/projects/filezilla/. In FileZilla, create a connection to the FTP server using the menu File->Site Manager. Click on New Site and type cs.umaine.edu as the host name. For Servertype, select SFTP using SSH2. Specify your gandalf username and click connect. You will be prompted for your password and, once entered, your home directory on gandalf will be displayed. You can now copy files back and forth between your local machine and gandalf. Since you are likely to be transferring binary files, you should select Transfer->Transfer Type->Binary, else your transferred files will be corrupted. For more information on FileZilla, use the Help option in its file menu, or see http://filezilla.sourceforge.net/documentation/.