Java:import com.sun.awt.AWTUtilities;报错

参考网址:http://stackoverflow.com/questions/860187/access-restriction-on-class-due-to-restriction-on-required-library-rt-jar

There‘s another solution that also works. I found it on this forum:

1、Go to the Build Path settings in the project properties.


2、Remove the JRE System Library


3、Add it back; Select "Add Library" and select the JRE System Library. The default worked for me.


This works because you have multiple classes in different jar files. Removing and re-adding the JRE lib will make the right classes be first

时间: 2024-12-22 16:44:21

Java:import com.sun.awt.AWTUtilities;报错的相关文章

JAVA中引用com.sun.awt.AWTUtilities时报错

JAVA中引用com.sun.awt.AWTUtilities时报错的解决办法[转] 在Eclipse中设置如下就可以了: When using com.sun.awt.AWTUtilities, Eclipse gives a error: - Access restriction: The method setWindowOpacity(Window, float) from the type AWTUtilities is not accessible due to restriction

linux 环境应用后台 java.lang.NoClassDefFoundError: sun.awt.X11GraphicsEnvironment 异常处理

Linux环境部署的应用,首页登录的验证码无法显示,密码框不加载. 该验证码是用java的图片包来处理图片的,查看后台日志,发现报 java.lang.NoClassDefFoundError: sun.awt.X11GraphicsEnvironment 异常,这是因为java虚拟机在处理图片时需要本地的x-server的支持,解决方法有两种: 1. java 1.4版本及以上 修改启动java参数,加上参数:-Djava.awt.headless=true 对于 websphere 则进入应

Control character in cookie value, consider BASE64 encoding your value , java操作cookie遇到中文会报错的解决方案

项目当中用到cookie保存中文,但是会报如下错误: Control character in cookie value, consider BASE64 encoding your value 大概意思是保存到cookie当中的值存在控制字符,无法保存.但实际上数据是不存在这种问题的.再看后面的那句话,好像是将要保存的值进行了base64编码,可能是因为中文在编码时出现乱码导致一些控制字符的出现.看来setCookie方法不支持保存中文(GBK)编码的样子. 解决方案:将要保存的值进行URLE

javat透明窗体问题(找不到com.sun.awt.AWTUtilities包)

Eclipse 默认把这些受访问限制的API设成了ERROR,而com.sun.awt.AWTUtilities提供的API是受限访问的.' 因此只要把Windows-Preferences-Java-Complicer- Errors/Warnings里面的Deprecated and restricted API中的Forbidden references(access rules)选为Warning就可以编译通过.

java插入数据至mysql数据库报错:check the manual that coresponds to your mysql server version for the right syntax to use near 'condition)values...解决方案

MySQL5.X(本地数据库) 使用java向表中插入数据时,每次数据库更新,pstm.executeUpdate();就会跳到IO报错,提示原因是sql语法有问题,如题可见 当测试插入数据不含condition字段时,插入成功,尝试更名为conDition时,仍报错 解决方案: 更改condition为conDi,原因可能时因为condition为数据库或java关键字不能使用,更名后不再受影响,插入成功. java插入数据至mysql数据库报错:check the manual that c

loadrunner java 缺少必要的导入包报错

loadrunner 运行从eclipse中做好的脚本,ctrl + A 复制到loadrunner中来, 添加参数化的的语句:verifyCode =    lr.eval_string ("<rand6>"); 报错: Notify: Found jdk version: 1.6.0. [MsgId: MMSG-22986]Notify: classpath=E:\performanceTest\3-性能测试\lr_hibox_script\;c:\program fi

Java客户端连接kafka集群报错

往kafka集群发送消息时,报错如下: page_visits-1: 30005 ms has passed since batch creation plus linger time 加入log4j.properties,设置为DEBUG级别,错误如下: 2017-06-03 17:33:31,417 DEBUG [org.apache.kafka.clients.NetworkClient] - Error connecting to node 2 at kafka-cluster-64bi

java客户端作为kafka的consumer报错org.I0Itec.zkclient.exception.ZkTimeoutException

出错现象: java客户端编程作为kafka的消费端,连接kafka的broker报错 出错原因分析: 当服务器配置或者网络环境较差时,会出现连接zk超时的情况出现; 解决方法:将程序中的timeout数值调大 props.put("zookeeper.session.timeout.ms", "15000");

【java开发系列】—— Tomcat编译报错

由于之前Eclipse里面有一个可移植性的web工程,但是在我很久没用后,再次登录这个IDE的时候就发现了问题. 首先,我的电脑里面有两个版本的JDK,1.6和1.7.两个版本的Tomcat6和7以及两个版本的Eclipse IDE 3.5和4.0+. 当我启动开发环境后,想要向server中添加应用,发现报错: There are no resources that can be added or removed from the server. 我之前好用的应用怎么回不好使呢.于是删除ser