您的位置:首页 > 编程语言 > Java开发

eclipse Java导入jar包提示Access restriction解决方法

2017-10-14 10:01 323 查看
在使用RXTXcomm.jar 编写串口通信程序提示错误:

Access restriction: The type ‘CommPortIdentifier’ is not API

(restriction on required library ‘C:\Program Files\Java\jre1.8.0_131\lib\ext\RXTXcomm.jar’)

问题原因:Eclipse 默认把这些受访问限制的API设成了ERROR

解决方法:

1. Windows-> Preferences -> Java -> Compiler -> Errors/Warnings ->Deprecatedand trstricted API -> Forbidden reference (access rules): -> Error改为Warning即可。

2. 只需要在projectbuild path中先移除JRESystem Library,再添加库JRESystem Library,重新编译后就一切正常了。

3. 工程上右键->工程属性->javabuilder path->Libraries标签,点击JRE SystemLibrary里面的Accessrules,addsun/** 为accessible,如果该项存在,就edit。

4. Windows-> Preferences -> Java -> Installed JREs -> 选择用的JDK-> Edit -> Add External JARs
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐