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

I try to use the following code:

ArrayList<String>
Map<String, String>

Eclipse complains about both of them: Syntax Error, parameterized types are only if source level is 1.5.

I use JDK 1.6, but even if I go to compiler and switch the compliance to 1.5. It still give me this error. Any Idea why?

This question is related to java eclipse

The answer is


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).


Go to Project properties.

Then 'Java Compiler' -> Check the box and "Enable project specific settings"

Uncheck the box to "Use Compliance from execution environment 'OSGi/Minimum-1.2' on the Java"

Then change the compiler compliance level to '1.5' and click Ok.

Rebuild it and your problem will be resolved.


I have experienced the same problem with Eclipse Indigo release - even though the project set up was correct. The main cause I suspect is that the workspace is defined in a separate folder from the actual source folders (as mentioned user748337). To fix the problem, I had to enable the project specific settings option (in the Porject preference) although it wasn't different from the workspace settings.


THIS CAN BE A QUICK FIX FOR ECLIPSE

When I was trying to create array list it gave error that array list cannot be resolved to type and something about "parametrised type are only in level 1.5"

Only I did was I tried to import java.util.ArrayList;

And that error went away.


Do the following..

Right-click on your project--> select properties-----> select Java Compilers

You wills see this window

Image for reference

Now check the checkbox ---> enable project specific settings.

Now set the compiler compliance level to 1.6

Apply then Ok

now clean your project and you are good to go


I'm currently working with Eclipse Luna. And had the same problem. You might want to verify the compiler compliance settings, go to "Project/Properties/Java Compiler"

The Compiler compliance level was set to 1.4, I set mine to 1.5,(and I'm working with the JDK 1.8); it worked for me.

And if you had to change the setting; it might be useful to go to "Window/Preferences/Java/Compiler" And check to see that the Compiler compliance level is 1.5 or higher. Just in case you have a need to do another Java project.


I get this fairly regularily. Currently what's working for me (with Photon) is:

  • Close project
  • Open project

If this doesn't work :

  • Close project
  • Exit Eclipse
  • Restart Eclipse
  • Open Project

I know, stupid isn't it.


Yes. Regardless of what anyone else says, Eclipse contains some bug(s) that sometimes causes the workspace setting (e.g. 1.6 compliant) to be ignored. This is even when the per-project settings are disabled, the workspace settings are correct (1.6), the JRE is correctly set, there is only a 1.6 JRE defined, etc., all the things that people generally recommend when questions about this issue are posted to various forums (as they often are).

We hit this irregularly, but often, and typically when there is some unrelated issue with build-time dependencies or other project issues. It seems to fall into the general category of "unable to get Eclipse to recognize reality" issues that I always attribute, rightly or wrongly, to refresh issues with Eclipse' extensive metadata. Eclipse metadata is a blessing and a curse; when all is working well, it makes the tool exceedingly powerful and fast. But when there are problems, the extensive caching makes straightening out the issues more difficult - sometimes much more difficult - than with other tools.


I was able to solve this in Eclipse Helios by right-clicking on the project, picking "Java Build Path", "Add Library...", "JRE System Library", "Workspace default JRE (jdk1.6.0_17)" and finally "Finish".


Single answer couldn't solve my problem so I used both :

  • First right click on the error in problems tab
  • click Quick fix
  • ok
  • right click on the project
  • build path
  • configure build path
  • remove JRE library
  • add JRE library

.... tada...done... :)


change the compiler version to lower value and do apply the changes. The compilation will fail.

Now update the version to required and do apply the changes, the workspace will get rebuild and the issue will get resolved.


Right click your project and choose properties in the properties dialog check the Java Compiler settings, maybe you have different workspace settings.


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".


It can be resolved as follows:

Go to Project properties.

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

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

Select the checkbox for "Use default compliance settings"


Be wary, too, of inheriting workspace settings in your projects for Java Compiler/Compliance settings. I had a project that was imported into Eclipse. Eclipse generated the project with a J2SE 1.4 JRE, compiler, and compliance settings.

When I went in and manually updated these settings and un-checked the "Enable project specific settings" box, I was still receiving build errors relating to 1.5 level compliance (even though the workspace settings were clearly 1.6). It wasn't until I re-checked the "Enable project specific settings" box and manually set the compiler/compliance levels to 1.6 did the errors go away.


This works for me .

In eclipse go to project properties -> java compiler.

Then change to java higher than 1.5 .

change Compiler compliance settings to 1.6 change Generated.class files compatibility to 1.6 change Source compatibility to 1.6

Thanks. Screen Shot for changes