java 报错 the type JOptionPane is not accessible due to restriction on required library ×

报错描述

Description Resource Path Location Type Access restriction: The method showInputDialog(Component, Object) from the type JOptionPane is not accessible due to restriction on required library /usr/lib/jvm/java-8-oracle/jre/lib/rt.jar

原因:类库权限不够无法访问 JOPtionPane。

解决办法

设置权限:
Eclipse->project->properties->Java Build Path->Libraries->Java System Libraries->Access rules下:
如果有javax/swing/JOptionPane 直接勾选,如果没有:
点击右边的Edit,弹出Type Access Rules:
Add:选择Accessiable,在rule pattern中输入:

javax/swing/JOptionPane

点击 OK
搞定收工

你可能感兴趣的:(java,报错)