今天在做JAVA编程实验,在使用Eclipse编译时出现了以下编译错误: Access restriction: The type JOptionPane is not accessible due to restriction on required library D:\ProgramFiles\Java\jdk1.8.0\jre\lib\rt.jar 在网上搜了一下,解决办法是修改编译
今天在做JAVA编程实验,在使用Eclipse编译时出现了以下编译错误:
Access restriction: The type JOptionPane is not accessible due to restriction on required library D:\Program Files\Java\jdk1.8.0\jre\lib\rt.jar
在网上搜了一下,解决办法是修改编译选项,方法如下:Window
-> Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted API -> Forbidden reference (access rules) -> Warnings,或者在项目上修改编译选项。
import javax.swing.JOptionPane; public class MyFirstApplication{ public static void main(String[] args){ JOptionPane.showMessageDialog(null,"Hello it is a joke!"); } }