Eclipse tip: How to build features that require Java 5

So you’re trying to create an Update Site and you hit the Build or Build All button. This is depending on a feature which includes plug-ins that require Java 5. The build fails and it tells you that there are errors in logs.zip. You unzip this and find this error:

Compliance level ‘1.4’ is incompatible with source level ‘1.5’. A compliance level ‘1.5’ or better is required

You double-check your settings and find that you have indeed set the compliance level to 1.5 on your workspace and none of your plug-in projects override this. Everything looks good (no red “x”es). What’s going on?

It turns out that features do not respect the Java compiler setting. Instead, they turn to whatever JVM you are running Eclipse with. Digging deeper, I think this is the PDE Build code that has this behavior, because it is used as well on the command line to automate the building of Eclipse features and plug-ins.

The solution? Run Eclipse with Java 5. This goes against the recommended practice of running on Java 1.4, but this is the only workaround that is available for this problem.

Further references: Bug 104960 – Compliance level error when building plugin. Thanks to Fabio of PyDev for intially reporting it.