Eclipse: Syntax Error, parameterized types are only if source level is 1.5

This workaround is helpful when this problem pops up.

1) Set Workspace JRE to 1.5 (and apply/save). Projects will rebuild.

2)Set Workspace JRE back to 1.6 (and apply/save). Projects will rebuild.

All errors are then gone (for now at least).


It can be resolved as follows:

  1. Go to Project properties.

  2. Then 'Java Compiler' -> Check the box ('Enable project specific settings')

  3. Change the compiler compliance level to '5.0' & click ok.

Do rebuild. It will be resolved.

Also, click the checkbox for "Use default compliance settings".


My guess would be that while you run eclipse itself with JDK 1.6, it's actually configured with a different default jre.

See Window->preferences->java->Installed JREs and make sure that the checked JRE is 1.6.

If the default JRE is indeed 1.6, chances are that it's a project specific setting. See that the project is configured to use the right JRE.

Tags:

Java

Eclipse