您好,欢迎访问一九零五行业门户网

The type JOptionPane is not accessible due to restriction on

今天在做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!); } }
import是引入的意思,javax.swing是sun为我们提供的一个包,包中有一个类叫 joptionpane。
joptionpane是有助于方便地弹出要求用户提供值或向其发出通知的标准对话框。它是用来编写图形用户界面的一个类。
合起来讲就是:导入包javax.swing中joptionpane这个类,这样在这个文件中就能使用这个类了。
其它类似信息

推荐信息