CS 211, 004/006
Lab Exercise-1
due Thursday, September 6th at noon


The objective of this lab is to be able to download all needed tools to build Java programs, and to use them to build and test some initial programs.

Overview:

  1. Download and install Java.
  2. Write two Java programs. The first will print "Hello, Lab!". second will print a CS quote.
  3. Download and use a tester module to ensure that your programs are correct
  4. Prepare the assignment for submission and submit it
This is a lab exercise on which collaboration (including discussing the solution on Piazza or searching online sources) is explicitly permitted. This will not be the case for other types of lab assignments or programming projects. It is still in your interest to understand and prepare your final submission yourself.

Installing Java:

Download a copy of the Java SDK. The Java JRE only contains the tools to run pre-built Java programs, but it does not let you build your own programs, so you want to be sure it is the JDK and not the JRE. Likewise, install a code editor (Dr Java is officially supported in this class). See https://cs.gmu.edu/~marks/211/textbook/01-getting-started.pdf if you need instructions on either.

Note on versions: either version 8 or 10 of the JDK is acceptable, however, the Dr Java IDE supported in this course is only configured for version 8. If you intend to use Dr Java, then be sure to install version 8.

Task:

First, write a program named HelloLab.java. Note that the spelling and capitalization make a difference! This will matter when you reach the testing section below. The program should print out "Hello, Lab!" (without the quotes).

The second task will have you write a program named CSWisdom.java. Like the first program, this one will only print output, but instead it will be a multi-line output:

Before software can be reusable,
it first has to be usable

- Ralph Johnson

Note that things like spacing and placement of newlines will affect whether the program passes the test.

Testing:

Download the following:

This is a unit tester which is what we will use to test to see if your program is working correctly. It will also let you see for yourself if the program is working correctly. It will check if your programs are correct by seeing whether their output matches the expected output. Here you see why two things are particularly important: the tester finds your code by name, so the spelling has to match; and it is looking for a certain expected output, so typos like extra spaces will cause it to fail.

When you think your programs are ready (you can run them even without the tester), do the following from the command prompt to run the tests.
On Windows:

javac -cp .;junit-cs211.jar *.java
java -cp .;junit-cs211.jar E1tester
On Mac or Linux:
javac -cp .:junit-cs211.jar *.java
java -cp .:junit-cs211.jar E1tester
In Dr Java:

Submission:

Submission instructions are as follows.

  1. Let xxx be your lab section number (one of 213-220), and let yyyyyyyy be your GMU userid. Create the directory xxx_yyyyyyyy_E1/
  2. Place the files HelloLab.java and CSWisdom.java in the directory you've just created.
  3. Create the file ID.txt in the format shown below, containing your name, userid, G#, lecture section and lab section, and add it to the directory. Your directory should contain three files total.

    Full Name: Donald Knuth
    userID: dknuth
    G#: 00123456
    Lecture section: 004
    Lab section: 213

  4. compress the folder and its contents into a .zip file, and upload the file to Blackboard.