您的位置:首页 > 产品设计 > UI/UE

项目实战—— 类型java.lang.charsequence不能解决(完美解决!)

2018-01-16 21:34 453 查看

问题:

   The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files

环境和配置

  我的myEclipse版本:

  Version: 10.7

  Build id: 10.7-20121026



编译器的版本:

   




问题的根源:

down
voteaccepted
Java 8 supports default
methods in interfaces. And in JDK 8 a lot of old interfaces now have new default methods. For example, now
in CharSequence we have chars and codePoints methods.

If source level of your project is lower than 1.8, then compiler doesn't allow you to use default methods in interfaces. So it cannot compile classes that directly on indirectly depend on this interfaces.

If I get your problem right, then you have two solutions. First solution is to rollback to JDK 7, then you will use old CharSequence interface without default methods. Second solution is to set source level of your project to 1.8, then your compiler will not
complain about default methods in interfaces.

 

解决方案:

   1、对JDK进行降级。 

   2、对IDE进行升级(或者换一个高版本的Eclipse、idea)

我的处理方案:

   降级Jdk到已有的低版本1.6:效果图





问题最终完美解决。

小结:

   关于这个问题,网上有很多的解决方案,但是都没有将问题的根源找出来,不求甚解有时候是很可怕的一件事情,容易将问题片面化,长久就会造成在解决问题的时候我的思维会出现只见树木不见森林的问题。

   我们应该要在时间精力允许的情况下,尽可能从本质上根源上发现问题解决问题。本人也是在stackoverflow这个网站上发现了有个高手讲的东西。道出了问题的根源。其实是由于IDE本身支持的编译器版本和jre版本不匹配导致的。攻城狮,还是需要扎实的英语功底啊!

56down
voteaccepted
Java 8 supports default
methods in interfaces. And in JDK 8 a lot of old interfaces now have new default methods. For example, now
in CharSequence we have chars and codePoints methods.

If source level of your project is lower than 1.8, then compiler doesn't allow you to use default methods in interfaces. So it cannot compile classes that directly on indirectly depend on this interfaces.

If I get your problem right, then you have two solutions. First solution is to rollback to JDK 7, then you will use old CharSequence interface without default methods. Second solution is to set source level of your project to 1.8, then your compiler will not
complain about default methods in interfaces.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐