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

后端 未结 17 1778
清酒与你
清酒与你 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:20

    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.

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

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

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

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

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

    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

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

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

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

    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.

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