Using Java 1.5 on Eclipse

Main Page

The C/C++ style enum class is a new feature to Java. To be able to compile programs using enum you need to have Java 1.5 (Java 2, Standard Edition 5.0) installed. The Linux machines in the CS cluster and the Mac machines in the MacLab all have Java 1.5 installed. I will say a bit more about installing on your home computer below. You must tell Eclipse that you want to use Java 1.5 to compile your programs. This page explains how.

Creating a new enum class

The new Java C/C++ style enum class for creating constants is quite a powerful addition. (To see an alternative way of creating constant objects in Java, compatible with pre-Java 1.5, see the discussion of enum in Thinking in Java.) Creating an enum class in a project is easy in Eclipse:

  1. Open up New by right-clicking on the Mouse (or + Mouse-Click on a Mac).

  2. This will open a new enum class Wizzard

    If you recieve a warning that Eclipse is not 5.0 compliant when you try to choose a name for your class

    Then you will need to proceed to the next section.
  3. Eclipse begins your new enum class

Making Eclipse 5.0 Compliant

You must have Java 1.5 installed to continue this section (see below for more details.)

  1. You do not need to have a project installed in Eclipse to change the compiler settings.
  2. Enter Window->Preferences

  3. Select Java->Compiler in the Preferences Wizzard

  4. Set the "Compiler Compliance Level" to "5.0"

    Select Apply. If you currently have a project in Eclipse you will be asked for a full rebuild. Agree to this:

  5. Now select OK. You are done.

Java 1.5 on your Home machine

Java 1.5 (Java 2, Standard Edition 5.0) is installed on all Linux machines in the CS cluster and the Mac machines in the MacLab. Java 1.5 can be obtained from the Sun site (for Window machines) or at the Apple site. (I believe Java 1.5 is only available for OS X.4, Tiger. Java 1.4.2 is the default version on the Mac.)


Main Page