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

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

    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.

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

    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.

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

    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.

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

    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"

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

    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.

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