Access restriction: The type 'JPEGCodec' is not API
Posted 雨临Lewis
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Access restriction: The type 'JPEGCodec' is not API相关的知识,希望对你有一定的参考价值。
问题
今天导入项目时Eclipse报错如下:
Access restriction: The type ‘JPEGCodec‘ is not API (restriction on required library ‘C:Program FilesJavajdk1.8.0_191jrelib
t.jar‘)
第一次遇到这种错误,百度了下,原来是因为Eclipse默认把访问受限的API设置成了Error级别,所以才会编译报错。
解决方法
方法一(推荐)
直接将项目的JRE给remove掉,然后再重新将JRE添加到项目中,操作如下:
- 右键项目,选择Properties -> Java Build Path -> Libraries -> 选中JRE System Library [jdkxxxx] -> 选择
Remove
- 接着选择
Add Librariy...
,重新加入JRE
方法二
修改Eclipse中关于访问受限的API的编译级别:
Window -> Preferences -> Java -> Compiler -> Errors/Warnings,选择Deprecated and restricted API
,将其中的Forbidden reference(access rules)
的级别选为Warning。
参考链接
以上是关于Access restriction: The type 'JPEGCodec' is not API的主要内容,如果未能解决你的问题,请参考以下文章
Access restriction: The method createJPEGEncoder(OutputStream) from the type JPEGCodec is not access
Access restriction: The type QName is not accessible due to restriction on required library
Access restriction : The constructor BASE64Decoder() is not accessible due to restriction on require
Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required libra
关于Access restriction: The type 'Application' is not API (restriction on required library)(示例
Access restriction:The type JPEGCodec is not accessible due to restriction on required library C:Pr(