The type JOptionPane is not accessible due to restriction on
程序员文章站
2022-06-08 21:41:58
...
今天在做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!"); } }
JOptionPane是有助于方便地弹出要求用户提供值或向其发出通知的标准对话框。它是用来编写图形用户界面的一个类。
合起来讲就是:导入包javax.swing中JOptionPane这个类,这样在这个文件中就能使用这个类了。
推荐阅读
-
使用JPEGImageEncoder类报The type JPEGImageEncoder is not accessible due to restricti
-
The type JOptionPane is not accessible due to restriction on
-
Access restriction: The type BASE64Encoder is not accessible due to restrict
-
Access restriction: The type BASE64Encoder is not accessible due to restrict
-
Access restriction: The type BASE64Encoder is not accessible due to restrict
-
Access restriction: The type BASE64Encoder is not accessible due to restrict