Access restriction: The method 'CharacterDecoder.decodeBuffer(String)' is not API...

怎么解决BASE64找不到JAR包问题,之前写过一篇,但是只记录了一种方法,本文列举三种解决方法:

最近维护以前的一个项目,发现用到BASE64编码解码的地方出现了错误提示,如下图所示:

Access restriction: The method 'CharacterDecoder.decodeBuffer(String)' is not API...

这是eclipse设置问题,eclipse默认把这些受访问限制的API设成了ERROR,下面列出几种解决方案:

方案一:

右键项目-->Build Path-->Configure  Build  Path-->JRE System Library-->Access rules-->Add,关键步骤截图如下:

Access restriction: The method 'CharacterDecoder.decodeBuffer(String)' is not API...

Access restriction: The method 'CharacterDecoder.decodeBuffer(String)' is not API...

 

Access restriction: The method 'CharacterDecoder.decodeBuffer(String)' is not API...

提示错误信息消失,错误解决:

Access restriction: The method 'CharacterDecoder.decodeBuffer(String)' is not API...

方案二:

Windows -> Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and trstricted API -> Forbidden reference (access rules): -> change to warning

Access restriction: The method 'CharacterDecoder.decodeBuffer(String)' is not API...

方案三:

在build path中先移除JRE System Library,再添加JRE System Library,重新编译后就可以了

Access restriction: The method 'CharacterDecoder.decodeBuffer(String)' is not API...