Java,AWTUtilities,eclipse报编译错误:Access restriction: The type 'AWTUtilities' is not API (restriction on required library 'C:\Program Files\Java\jre7\lib\rt.jar')

【场景】调用com.sun.awt.AWTUtilities时,eclipse提示编译错误:

Access restriction: The type ‘AWTUtilities‘ is not API (restriction on required library ‘C:\Program Files\Java\jre7\lib\rt.jar‘)

【分析】eclipse项目默认的jre版本较早。

com.sun.awt.AWTUtilities是在JDK 6 update10中增加的。

【解决】更换JRE

方案一:为eclipse更换默认JRE

方案二:为项目更换JRE

1、项目上右击,快捷菜单,Build Path -> Configure Build Path...

2、列表树中选中Java Build Path,选项页中选中Libraries页

3、选中JRE项,Remove

4、Add Library

5、选中JRE System Library,Next

6、选中Alternate JRE,下拉列表中选择您的JRE,Finish

7、OK

Java,AWTUtilities,eclipse报编译错误:Access restriction: The type 'AWTUtilities' is not API (restriction on required library 'C:\Program Files\Java\jre7\lib\rt.jar')

时间: 2024-11-02 23:25:43

Java,AWTUtilities,eclipse报编译错误:Access restriction: The type 'AWTUtilities' is not API (restriction on required library 'C:\Program Files\Java\jre7\lib\rt.jar')的相关文章

Access restriction:The type JPEGCodec is not accessible due to restriction on required library C:\Program Files\Java\jre6\lib\rt.jar 报错

报错: Access restriction:The type JPEGCodec is not accessible due to restriction on required library C:\Program Files\Java\jre6\lib\rt.jar   解决方法: Project -> Properties -> libraries, 先remove掉JRE System Library,然后再Add Library重新加入. 将jre项目用自己下载的jre

关于Access restriction: The type 'Application' is not API (restriction on required library)

原文链接:http://rxxluowei.iteye.com/blog/671893 今天写第一次写JavaFX的入门程序就GG 遇到了导入API的问题,无奈疯狂地通过网络找解决方案.. 我的问题是: 导入import javafx.application.Application;时 出现这个错误提示 Access restriction: The type 'Application' is not API (restriction on required library 'C:\Progra

Access restriction: The type 'Resource' is not API (restriction on required library 'G:\JAVA\jdk\lib

问题: 打入JFrame时候,会报错:Access restriction: The type 'Resource' is not API (restriction on required library 'G:\JAVA\jdk\lib 解决方式: 项目属性preferences>java build path>把右侧[libraries中的JRE System Library]删除重新导入. Access restriction: The type 'Resource' is not AP

启动Eclipse时,出现 “Failed to load the JNI shared library "C:\Program Files\java\jdk1.7.....\jvm.dll"

原因1:给定目录下jvm.dll不存在. 解决方法:(1)重新安装jre或者jdk并配置好环境变量.(2)copy一个jvm.dll放在该目录下. 原因2:eclipse的版本与jre或者jdk版本不一致 解决方法:要么两者都安装64位的,要么都安装32位的,不能一个是32位一个是64位. 先确定Eclipse是多少位的,32 or 64, 在 Eclipse的安装目录下的 eclipse.ini 文件中,"--launcher.library"下,如果有win32.x86,就是32位

Eclipse 编译错误 Access restriction:The type *** is not accessible due to restriction on... 解决方案

原文链接:http://rxxluowei.iteye.com/blog/671893. Eclipse 编译时报错:         Access restriction:The type JPEGCodec is not accessible due to restriction on required library C:/Program Files/Java/jre6/lib/rt.jar         解决方法:         Project -> Properties -> l

Access restriction: The type 'BASE64Decoder' is not API

Access restriction: The type 'BASE64Decoder' is not API (restriction on required library 'C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar') http://blog.csdn.net/jbxiaozi/article/details/7351768 Access restriction: The type 'BASE64Decoder' is not API

2015/5/7 Access restriction: The type 'BASE64Encoder' is not API

Access restriction: The type 'BASE64Encoder' is not API (restriction on required library 'D:\Java\jdk1.6.0_43\jre\lib\rt.jar') 引入import sun.misc.BASE64Encoder; 是红叉,怎么解决? 右键项目,点属性(Properties): java bulid path-->Libraries-->jre System Library: Access

Access restriction: The type 'BASE64Encoder' is not API

问题的原因好像是这个方法不是安全的,所以不推荐使用,我是在做毕设时要用到的所以就直接用了(毕设要求没有那么严格的要求) Access restriction: The type 'BASE64Encoder' is not API (restriction on required library '/home/rocky/develop/jdk1.8.0_65/jre/lib/rt.jar') Access restriction: The type 'BASE64Encoder' is not

Eclipse报错 due to restriction on required library C:/Java/jdk1.7.51/jre/lib/rt.jar 解决方案

Eclipse报错 due to restriction on required library C:/Java/jdk1.6.0_10/jre/lib/rt.jar 解决方案 Eclipse 编译时报错: Access restriction:The type NEW is not accessible due to restriction on required library C:/Java/jdk1.6.0_10/jre/lib/rt.jar 解决方法如下:  1.进入Project -