CS 1054: Introduction to Programming in JAVA

CS 1054 Introduction to Programming in Java (Spring 2008)

Lab 1: Compiling and executing Java programs

Lab Objectives

Instructions

For this first lab, you will carry out the following instructions and you will be graded according to whether you have accomplished each of these very simple steps. Make sure you inform your TA as you correctly compile and execute each program so that he can mark you off in a gradesheet. You may ask help from the TAs at any point in time during the lab. Since you will write Java programs for this lab, you may use the first program we used in class (shown below) as a reference. Although you may cut and paste the code, you are advised to type from scratch as this will help you get used to the editor and compiling process.
// HelloPrinter.java

public class HelloPrinter
{
   public static void main( String args[] )
   {
      System.out.println( "Hello, world." );
   }
}

  1. Create a work folder on your lab machine and place a copy of "cmdhere.bat" in that folder. The labs have a different version of Java installed so use this cmdhere.bat version (right click, then choose "Save Target As..." and place in the appropriate folder). Double-click on "cmdhere.bat" to begin the command line portion of this lab.
  2. Using the command line, create, compile and execute a program called "NameInBox.java" that prints three lines, showing your first name enclosed in a box. Use the keyboard characters - (dash), + (plus), and | (bar) for the box boundaries. When you execute your program, the output would look like this (using your name instead of mine):
    +-----------+
    | John Paul |
    +-----------+
    
    Once you have successfully executed your program, show your screen to the TA.
  3. Invoke BlueJ, and create a project called Lab1.
  4. Within the Lab1 project, create a class called Stairs (Stairs.java). The program should print the following:
                +---+
                |   |
            +---+---+
            |   |   |
        +---+---+---+
        |   |   |   |
    +---+---+---+---+
    |   |   |   |   |
    +---+---+---+---+
    
    Once you have successfully executed your program, show your screen to the TA.
  5. Quit BlueJ. Look for the folder containing your Lab1 project. Zip this folder and keep a copy of the zip file or send to your own email. Show your TA that you have successfully created that zip file. (You will likely need to do this during the labs this semester if you want keep a copy of your work).