Eclipse Installation and Use

For Pomona CS 51 Students

This document answers questions particularly related to the use of Eclipse in CS 51 at Pomona College. The official Eclipse FAQ is available from eclipse.org.

  1. How do I install Eclipse on my own computer?
  2. How do I create a new project?
  3. How can I add a class to a project?
  4. How can I add an image or sound file to a project?
  1. How do I install Eclipse on my own computer?

    There are several things you need to do to install Eclipse on your computer:

    1. Install the Java JDK (Java Development Kit)
    2. Download and install Eclipse from http://www.eclipse.org/downloads/index.php. Be sure to download the most recent stable version for your operating system (3.1.1 when this document was written).
    3. Download objectdraw.jar from http://cortland.cs.williams.edu/~cs134/eof/library/. Remember where you download this because you will need to tell Eclipse where it is.
    4. Start Eclipse.
      • Open the Window menu and select Preferences.
      • Click on the icon to the left of Java to expand the Java choices.
      • Expand Build Path and then select Classpath Variables.
      • Click the New button.
      • For the name, enter OBJECTDRAW. Be sure to spell it exactly like this and in all capitals.
      • For the Path, click the File button and find the objectdraw.jar file you just downloaded.
      • Click OK and OK again.

  2. How do I create a new project?

    1. Open the "File" Menu. Select "New" and then "Project" from the submenu.
    2. Select "Java Project", which may be showing at the top level or you may have to open the Folder labeled "Java" to find it, and then click "Next".
    3. Enter the Project name.
    4. If you are not planning to use objectdraw, click Finish and skip the rest of the steps. If you are planning to use objectdraw (the usual case), click Next.
    5. Select the "Libraries" tab.
    6. Click "Add variable".
    7. Select OBJECTDRAW from the list and click "OK".
    8. Click "Finish".

  3. How can I add a class to a project?

    First you should make sure the project you wish to add the class to is selected in the Package Explorer. Then there are two options. You can open the "File" menu, select "New" and then "Class" from the submenu. Alternatively you can click on the "C" icon just above the line separating the "Package Explorer" and "Editor" panes. You can also use the menu next to the "C" to select "Interface" if that is what you want to create.

    When a new dialog box appears, make sure that the name of the project is listed as the "Source folder". If not, use the browse button to find the correct project. In the "Name" field, type the name of the new class. While you can add information in the "Superclass" and "Interfaces" fields, it is often simpler just to add it yourself after the class has been created. Click on "Finish" to finish creating the new class as part of your project.

  4. How can I add an image or sound file to a project?

    The following technique can be used to import any type of file into an Eclipse project, not just image and sound files. The files will be copied into the project.

    1. Select the project to import the file(s) into in the Project Explorer panel.
    2. Open the File menu. Select Import. Select File system. Click Next.
    3. Click the Browse button. Find the folder containing the files to import. Select Choose.
    4. Click on the folder name (not the check box) in the left column.
    5. Select the files to import in the right column.
    6. Click Finish.