Get Eclipse to use Java 5.0

Problem
I am running Eclipse 3.1.1 with Java 1.5 (Java 5). Oddly enough, Eclipse was not allowing me to use generics in my Java programs, even though the J2SDK 1.5 was in the classpath. (I have the sun-j2re1.5 and sun-j2sdk1.5 packages installed.)
Solution

The trick is to set the "compiler compliance level" in the preferences.

  1. In the menu bar, choose Window -> Preferences...
  2. In the Preferences dialog box, choose Java -> Compiler
  3. Set the field "Compiler compliance level" to "5.0"

When you create a project, you are given the option of using the Eclipse default or setting a specific compiler compliance level.

Explanation
You don't always want to compile using the most cutting-edge version of Java. For production work you'll want to drop down a level to 1.4.2. Eclipse assumes you will not want to use the latest Java technology for mos projects.
Resources

No comments yet. Commenting is not yet reimplemented after the Wordpress migration, sorry! For now, you can email me and I can manually add comments. Feed icon