import javax.swing.JFrame;
import javax.swing.JLabel;
出错原因是Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
实在不知道是为什么,哪位高人指点下,难道有什么该装的东西没装
14 个解决方案
#1
楼主的JDK是不是没装好……
你工程中引用的JAVA库的位置找不到JAVA库文件
修改一下工程的引用的库文件位置
或者将JDK装到C:\Program Files\Java\jdk1.6.0_18\
你工程中引用的JAVA库的位置找不到JAVA库文件
修改一下工程的引用的库文件位置
或者将JDK装到C:\Program Files\Java\jdk1.6.0_18\
#2
楼主你建的工程里用的JDK有问题,在建工程的时候手动改一下导入的JDK就行了
#3
JDK没装好?不能吧,除了swing不行,其它的都没问题啊,用java也有一阵了,难道需要什么特殊的东西
#4
2楼能不能给具体讲解下,需要改成什么样子
#5
不懂,頂上!
#6
额。。。。是不是jdk和jre都是1.6的?? windows---》Preferences ----》java--》Compiler 目录下看看 JDK Compiler是否是1.6哇?? 我用的eclipse 不知道lz用的啥?
#7
如果用的是eclipse
现在工程上右键点击,刷新一下(Refersh)
在工程下方有JRE System Library [jre6]
点开
看有没有rt.jar这个,注意后面的路径
点开
看能否找到
javax.swing这个包,如果没有,重装下JDK吧
现在工程上右键点击,刷新一下(Refersh)
在工程下方有JRE System Library [jre6]
点开
看有没有rt.jar这个,注意后面的路径
点开
看能否找到
javax.swing这个包,如果没有,重装下JDK吧
#8
汗,楼上的各位同志,我用的就是eclipse啊,windows---》Preferences ----》java--》Compiler 查过了,是1.6啊,JRE System Library底下的rt.jar也查了,有javax.swing啊
可是就是不行啊,实在是郁闷,就最简单的一个程序,想看看swing能不能用就这样了,我把错误完整的贴一下
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The constructor JFrame(String) is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JLabel is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The constructor JLabel(String) is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JLabel is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The method getContentPane() from the type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The method setDefaultCloseOperation(int) from the type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The field EXIT_ON_CLOSE from the type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
可是就是不行啊,实在是郁闷,就最简单的一个程序,想看看swing能不能用就这样了,我把错误完整的贴一下
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The constructor JFrame(String) is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JLabel is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The constructor JLabel(String) is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JLabel is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The method getContentPane() from the type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The method setDefaultCloseOperation(int) from the type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The field EXIT_ON_CLOSE from the type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
#9
从来没用过 但是对这个很好奇 可能不久打算学 所以进来学习..
#10
嘿嘿,我是用记事本开发的
#11
哎,我查了半天,好像这个安装就不应该是个问题,oracle的tutorial里也没说这问题,哪位大侠指点指点我吧,急死人了
#12
试试这个方法:
windows --> Preferences --> java --> Compiler --> Errors/Warnings
点击按钮“Restore Defaults”
点击按钮“OK”
windows --> Preferences --> java --> Compiler --> Errors/Warnings
点击按钮“Restore Defaults”
点击按钮“OK”
#13
我终于明白了,是我的jdk library的问题,我到property-->java build path -->library里面把原来那个旧的删除了,重新加上了jdk1.6就好了,原来那个不知道怎么搞的变成了jdk什么minimum,虽然库都有,但是就是不能用。再次感谢大家的帮忙
#14
说明有编译错误。
请查看该项目的java build path里面是否正确引入了JRE Systen Library,选中项目-->右键-->BuildPath-->Config BuildPath或者从Project-->Properties--……。以及代码的import是否完整。可以在代码编辑界面按下Ctrl+Shift+O(默认),规范倒入包。
请查看该项目的java build path里面是否正确引入了JRE Systen Library,选中项目-->右键-->BuildPath-->Config BuildPath或者从Project-->Properties--……。以及代码的import是否完整。可以在代码编辑界面按下Ctrl+Shift+O(默认),规范倒入包。
#1
楼主的JDK是不是没装好……
你工程中引用的JAVA库的位置找不到JAVA库文件
修改一下工程的引用的库文件位置
或者将JDK装到C:\Program Files\Java\jdk1.6.0_18\
你工程中引用的JAVA库的位置找不到JAVA库文件
修改一下工程的引用的库文件位置
或者将JDK装到C:\Program Files\Java\jdk1.6.0_18\
#2
楼主你建的工程里用的JDK有问题,在建工程的时候手动改一下导入的JDK就行了
#3
JDK没装好?不能吧,除了swing不行,其它的都没问题啊,用java也有一阵了,难道需要什么特殊的东西
#4
2楼能不能给具体讲解下,需要改成什么样子
#5
不懂,頂上!
#6
额。。。。是不是jdk和jre都是1.6的?? windows---》Preferences ----》java--》Compiler 目录下看看 JDK Compiler是否是1.6哇?? 我用的eclipse 不知道lz用的啥?
#7
如果用的是eclipse
现在工程上右键点击,刷新一下(Refersh)
在工程下方有JRE System Library [jre6]
点开
看有没有rt.jar这个,注意后面的路径
点开
看能否找到
javax.swing这个包,如果没有,重装下JDK吧
现在工程上右键点击,刷新一下(Refersh)
在工程下方有JRE System Library [jre6]
点开
看有没有rt.jar这个,注意后面的路径
点开
看能否找到
javax.swing这个包,如果没有,重装下JDK吧
#8
汗,楼上的各位同志,我用的就是eclipse啊,windows---》Preferences ----》java--》Compiler 查过了,是1.6啊,JRE System Library底下的rt.jar也查了,有javax.swing啊
可是就是不行啊,实在是郁闷,就最简单的一个程序,想看看swing能不能用就这样了,我把错误完整的贴一下
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The constructor JFrame(String) is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JLabel is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The constructor JLabel(String) is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JLabel is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The method getContentPane() from the type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The method setDefaultCloseOperation(int) from the type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The field EXIT_ON_CLOSE from the type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
可是就是不行啊,实在是郁闷,就最简单的一个程序,想看看swing能不能用就这样了,我把错误完整的贴一下
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The constructor JFrame(String) is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JLabel is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The constructor JLabel(String) is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JLabel is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The method getContentPane() from the type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The method setDefaultCloseOperation(int) from the type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
Access restriction: The field EXIT_ON_CLOSE from the type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_18\jre\lib\rt.jar
#9
从来没用过 但是对这个很好奇 可能不久打算学 所以进来学习..
#10
嘿嘿,我是用记事本开发的
#11
哎,我查了半天,好像这个安装就不应该是个问题,oracle的tutorial里也没说这问题,哪位大侠指点指点我吧,急死人了
#12
试试这个方法:
windows --> Preferences --> java --> Compiler --> Errors/Warnings
点击按钮“Restore Defaults”
点击按钮“OK”
windows --> Preferences --> java --> Compiler --> Errors/Warnings
点击按钮“Restore Defaults”
点击按钮“OK”
#13
我终于明白了,是我的jdk library的问题,我到property-->java build path -->library里面把原来那个旧的删除了,重新加上了jdk1.6就好了,原来那个不知道怎么搞的变成了jdk什么minimum,虽然库都有,但是就是不能用。再次感谢大家的帮忙
#14
说明有编译错误。
请查看该项目的java build path里面是否正确引入了JRE Systen Library,选中项目-->右键-->BuildPath-->Config BuildPath或者从Project-->Properties--……。以及代码的import是否完整。可以在代码编辑界面按下Ctrl+Shift+O(默认),规范倒入包。
请查看该项目的java build path里面是否正确引入了JRE Systen Library,选中项目-->右键-->BuildPath-->Config BuildPath或者从Project-->Properties--……。以及代码的import是否完整。可以在代码编辑界面按下Ctrl+Shift+O(默认),规范倒入包。