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

后端 未结 17 1779
清酒与你
清酒与你 2020-12-13 01:55

I try to use the following code:

ArrayList
Map

Eclipse complains about both of them: Syntax Error, para

相关标签:
17条回答
  • 2020-12-13 02:27

    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.

    0 讨论(0)
  • 2020-12-13 02:27

    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.

    0 讨论(0)
  • 2020-12-13 02:32

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

    0 讨论(0)
  • 2020-12-13 02:33

    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.

    0 讨论(0)
  • 2020-12-13 02:38

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

    0 讨论(0)
  • 2020-12-13 02:39

    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.

    0 讨论(0)
提交回复
热议问题