Eclipse Error: java.lang.CharSequence cannot be resolved

前端 未结 2 496
耶瑟儿~
耶瑟儿~ 2021-02-08 11:19

I\'m getting a error trying to compile a simple code in Eclipse. I\'m using jre8.

For example, when I try to compile this code:

import java.util.ArrayLis         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-02-08 12:02

    Ensure that your Eclipse IDE supports Java 8:

    The first Eclipse version supporting Java 8 was Eclipse Kepler SR2 (4.3.2) with an additional patch. (See: Installing Java™ 8 Support in Eclipse Kepler SR2, and the corresponding Marketplace Item that needs to be installed: Java 8 support for Eclipse Kepler SR2).

    In my opinion you should udpate to the latest Eclipse Version.

    With Luna SR2 (4.4.2) no additional patch is necessary.


    Ensure the 1.8 JRE is available in your Workspace:

    Windows > Preferences: Java > Installed JREs

    Installed JREs

    If this is not the case you can add a new JRE with the add button.


    Ensure that JRE System Library == JavaSE-1.8 for your Project

    In the Package Explorer, you should see the Java version:

    Package Explorer

    If this is not correct you should open the context menu the JRE System Library item and select the Properties menu entry.

    JRE System Library - Properties

    In your project you have a .classpath file (Use the Navigator View if you do not see the file), that should looks like this:

    
    
        
        
        
    
    

    Rebuild your project

    Project Menu > Clean...

    Select your project from the list or "Clean all projects" and "Start a build immediately"


    See also:

    • Explaination from @mkrakhin in his answer: The type java.lang.CharSequence cannot be resolved in package declaration

提交回复
热议问题