CS 49J - Lab 1

Cover page image

Cay S. Horstmann

Lab Rules

Step 1. Housekeeping

  1. Did you sign up to Piazza?
  2. Did you upload your picture to Canvas?

Step 2. Eclipse

  1. Open Eclipse. Make a new Java project lab1. Make a new class Hello. Be sure it is in the default package. Clear out the Package: field. Then paste in this code:
    public class Hello
       public static void main(String[] args)
          System.out.println("Hello \uD83D\uDE3B!");
    Run the program. What happens?
  2. Change main to Main. Compile and run. What happens?
  3. Change it back. Change System.out to System.uot. What happens?
  4. Change it back. Move the cursor after the second ", i.e. before the );. Type a period and to. If nothing happens, hit Ctrl+Space. (Might be Option+Space on the Mac.) What happens?
  5. Select toUpperCase() and run the program again. What happens?

Step 3. Book Code

  1. Unzip the book code somewhere on your computer. (Link on course web page...)
  2. In Eclipse, make a new project. But this time, uncheck the box Use default location. Then browse to corejava/v1ch02/ImageViewer whereever you unzipped the book code. Note that the project name is set to ImageViewer. Click Finish.
  3. Run the app. What does it do?
  4. Glance at the code. In your opinion, is that a lot of code for writing such an app, or not very much code at all?

Step 4. The Command Line

  1. Open a terminal window. Type
    javac -version
    What happens? (If you get an error message and don't know how to fix it, ask for help.)
  2. Change to the corejava/v1ch02/Welcome directory in the terminal.
  3. Run
    javac Welcome.java
    java Welcome
    What happens?
  4. What happens when you run
    javac Welcome
    ? Why?
  5. What happens when you run
    java Welcome.java

Step 5. CodeCheck

Step 6. CodeCheck and Eclipse

Step 7. CodeCheck and Eclipse Part 2

Step 8 (Optional). The Most Frequent Element