For each assignment, you must turn in your programs. There should also be a description of how your program is supposed to work. The program description is an important part of your work and will contribute significantly to your assignment grade. In many cases it suffices to include comments in your code. Don't go overboard with verbosity. Javadoc comments should be sufficient for small programs. Other times, this format would be too tedious, in which case you may submit a separate writeup. It might have a file name such as Yang1.txt or even Yang8.doc. We would much rather have a text file than a Word document, but some students seem to be addicted to Word, and we don't want to cause unnecessary withdrawal symptoms.
If you create a test class to put your program through its paces, include that in your submission. (We explain how to submit multiple files below.) However, what's more important is to provide some kind of print-out of what your program did. Often you can just copy and paste the interaction pane from an IDE session. For simple cases, you don't need a test class, because you can essentially create one on the fly by typing variable definitions, method definitions, and method calls in the interaction pane. Some assignments require interaction with a GUI. If so, you obviously can't provide a record of everything the program did, but provide whatever you can.
All assignment will involve handing in multiple files. These are to be bundled together into a '.jar' file. A jar file is a file that contains a bunch of other files. ("jar" stands for "java archive.")
Some IDEs allow you to create jar files by pressing buttons. But not all IDEs do so. For example, DrJava does not allow you to create jar files by pressing buttons. Thus, many students in the class might be using the jar command in a command-line window, or "shell."
To start a common-line window, please see "Step 2: Setting up Environment" of own_install_compile_run.html.
Now you need to change the current directory of your command-line window to the directory where you store your files. Suppose you have stored your files under the directory C:\Users\yry\classes\cs112\prob1. (Unix and Mac will use / instead of \.) To change directory in a command line, use the command cd, e.g,,
cd C:\Users\yry\classes\cs112\prob1
When you are at the directory
where you have stored your files, to create a
jar file, type
jar cvf NNN.jar file1 file2 ... fileK
where NNN is the name of the jar file, and fileI is the
Ith file to include. The included files don't have to come from the
current directory, but their names must include whatever directory they do come
from. To include all the Java files in a directory, write *.java.
Example: Suppose you have gotten your program running, and it consists of two Java files and text file, with names Spiffy.java, Neato.java, and Glib.txt. The first two are in the current directory, and the third is in the subdirectory extra. Type:
jar cvf NetIDpN.jar Spiffy.java Neato.java extra\Glib.txtN is the assignment number. This should produce the file 'NetIDpN.jar' . So for assignment 1, if your netid is yry3, you would write
jar cvf yry3p1.jar Spiffy.java Neato.java extra\Glib.txt(Here we're assuming you're using a Windows machine, so that the backslash ("\") is the appropriate directory delimiter. For a Macintosh or other Unix-based system, you would use an ordinary slash ("/").)
Careful: If you forget the jar file name, and just write
jar cvf Spiffy.java Neato.java extra/Glib.txtyou will overwrite the file Spiffy.java.
To see the contents of a jar file, write jar tvf jarfilename. You will get a list of all the files it contains. If you want to extract the files in a jar file, type jar tvf jarfilename.
The biggest nuisance students encounter when trying the procedures listed above is that the operating system doesn't recognize jar as a command. You'll get a message such as
'jar' is not recognized as an internal or external command, operable program or batch file.
The problem is that for Windows (or any other OS) to know how to carry out a command, it must be able to find the program associated with its name. Please check the help page (own_install_compile_run) about Setting Up Environment.
Continue the steps in own_install_compile_run.html:
Finally, just upload the jar file from the Assignments submission page (Navigation Tools/Assignments) on classv2.
Last modified: Saturday January 22, 2011 12:43:21 AM -0500