Back to syllabus

The bulk of this lab is in installing Eclipse and the ACM library, the software we will use to program in Java all semester. This lab is not typical of labs in this course. Most of the time, you’ll be working with a partner/group to solve problems. But before we can do that fun stuff, we have to install the software.

Note that while Eclipse does work on Linux, it does not work on ChromeOS. Chromebooks generally do not have enough computing power to be able to use in computer science courses. If your computer is a Chromebook, then you will have to use lab computers to complete the coursework.

The instructions below sometimes call out special instructions for macOS and for Windows users. If you have neither of these (because you have Linux, or something even more exotic), then just do your best. I’m happy to help.

  1. Configure your computer to show file extensions:
  1. Download cs113.zip to a convenient spot where you wish to store your coursework. On many computers, it will end up in your Downloads folder. Don’t leave it there – put it somewhere you won’t lose it. (Please, don’t just put it on your desktop!)

  2. Expand the .zip file.

  1. Download Eclipse by clicking the main download button on this page (“Get Eclipse OXYGEN”) and following the instructions. On a Mac, you get a compressed file you will have to double-click to expand; Windows users just get the installer exe directly. Either way, run the installer.

    Eclipse is an integrated development environment (IDE) that will make Java programming much easier than it would be otherwise.

    Mac users: Many have had trouble with Java versions. If you are told to download a “legacy” Java at this point (with a More Info... button), do so. You may also need to download the macOS version of Java from this page (and no other). Choose the macOS link from the topmost set of downloads.

  2. Follow the directions in the installer, choosing the “Eclipse IDE for Java Developers” when given a menu of choices. At the end of installation, click the green Launch button.

  1. You will be asked to “Select a directory as workspace”. Choose Browse... and navigate to the cs113 folder you unpacked from the cs113.zip file in step 3.
  1. Create your first project by clicking the down-arrow next to the leftmost icon in the toolbar (it’s a window with a + in the corner). Choose to create a Java Project.

  2. Name the Project Lab01. (The exact characters in the name don’t matter much, but there can’t be any spaces or punctuation.) Click the Next > button, not the Finish button.

  3. In the next screen that appears, click the Libraries tab and then the Add External JARs... button. Choose the acm.jar file that should be right there. (If it’s not right there, navigate to your cs113 folder; the acm.jar file is inside.) After choosing the acm.jar file, click Finish to create the project.

  4. Create a new Java class (a class is the fundamental unit of Java code) by clicking the green circle button with a C and a + on it (around the middle of the toolbar). Name the class HelloWorld (no spaces or punctuation here!) and click Finish.

    You should have a file that looks like this appear:


public class HelloWorld
{

}
  1. Edit the file so that it looks like this:
import acm.graphics.*;
import acm.program.*;

public class HelloWorld extends GraphicsProgram
{
  @Override
  public void run()
  {
    GLabel message = new GLabel("Hello, world!", 10, 20);
    add(message);
  }
}

Be very careful about punctuation and capitalization here. Java is sensitive to these details!

  1. The program is now ready to run. Run it as an applet by clicking the “play” button (green button with a white triangle pointing right in it). A window should appear greeting the world. (You will likely get some red text in Eclipse with an error about an AppletViewer properties file. That happens the first time you run a Java program on your computer and then never again. Don’t worry about it.)

  2. Below the final }, make a new line in the file and type /* */. These characters tell Java that what you write in between is a comment and does not affect the way the program runs.

  3. Type the answers to the following questions in your file, in between the /* and the */. You will need to experiment a little to figure this out.

    1. How can you change what your program displays? For example, make your program display “Good afternoon, computer!” instead of “Hello, world”. What did you need to do to get this to work?

    2. How can you change the location of the text in the window? For example, say you wanted to move the text to the right. How would you do that?

    3. How can you make two different chunks of text appear?

  4. You’re just about done. Now, you will submit your work. It will not be graded, but submitting allows us to work out any kinks in the submission system. You will be using Gradescope for submitting all the work in this course; the site also allows the course staff to return graded work to you. Go to the Gradescope website and sign up. (It’s free for students, and Gradescope meets the privacy requirements of handling student data.) Use your College email address. When filling out your name, write it surname first; I would enter Eisenberg, Richard. (This helps connect to other systems working behind the scenes. Surnames are less fungible than forenames!)

    At some point during the registration process, you will need a course code; this is what Gradescope uses to link your account with mine. This code is 9GEG3Y.

  5. Export your project:

    1. Select your Lab01 project in Eclipse.
    2. Right-click and choose to Export...
    3. The Export dialog box appears. Under General, choose Archive File and click Next.
    4. Make sure your project is selected in the list at the top-left of the window and that Save in zip format and Create directory structure for files are selected toward the bottom.
    5. Browse... to find a good spot to save the file that wil be exported. Name the file Lab01.zip.
    6. Click Finish. Eclipse will create Lab01.zip as directed.
  6. Submit your Lab01.zip file as your submission for lab01.

  7. When you’re all done, call me over and tell me of your success.

  8. If you have time, play around. See what you can draw!