Wednesday, September 12, 2007

Changing ECLIPSE workspace JRE and Java compiler setting

I wanted to upgrade my ECLIPSE workspace to use Java 5 by default rather than Java 1.4.2. I changed my JAVA_HOME and JDK_HOME env vars but that didn't help. When creating a new project, ECLIPSE continued to pick up the 1.4.2 JRE as seen under Project...Properties. The JRE preference seems to be at the workspace not project level. To change the JRI, Window...Preferences. Open up the tree under 'Java'. Choose "Installed JREs". If there's only one there, you can't remove it. Click 'Add...'. Browse to the base directory of the Java installation, e.g. /usr/java/jdk1.5.0_08. Give the JRE a name and click OK. This adds the new JRE to the list of JREs available. To select it as the default JRE, it must be checked in the Installed JREs window.

But that's not all. I still couldn't add statements that used the new enum type even after doing all the above. In addition, one must make a change to the workspace for the compiler: Window...Preferences. Click on 'Compiler' - don't expand the tree. On the page in left pane, change the Compiler compliance level to 5.0.
I'm not sure, but I assume that the '5.0' choice wouldn't have even been there if I had not changed my JDK_HOME and JAVA_HOME env vars already.

No comments: