今天新建一个类的时候,很多元素报错,说引用不到:

 Access restriction: The type NoSuchPortException is not accessible due to restriction on required library C:\Java\jre7\lib\ext\comm.jar

Access restriction: The type XXX is not accessible due to restriction on required library XXX_启动错误

 这个comm.jar 是在项目中后来引用的,并不是java自带的,

Access restriction: The type XXX is not accessible due to restriction on required library XXX_启动错误_02


那怎样解决这个引用不到的问题呢?网上搜到了答案:

右击项目,Build Path -> Configure Build Path,在对话框中选择 Order and Export 标签,把comm.jar的位置移动到JRE System Library 的上面

Access restriction: The type XXX is not accessible due to restriction on required library XXX_启动错误_03

效果如下:

Access restriction: The type XXX is not accessible due to restriction on required library XXX_启动错误_04


报错信息消失。