类加载器拒绝访问 AudioPlayer
我将程序文本复制到另一台计算机,但导入 sun.audio.AudioPlayer
类时出现一些问题。编译器在导入字符串上加下划线,当我将鼠标放在它上面时,会出现以下文本,我不太明白:
访问限制:由于所需库的限制,
AudioPlayer
类型无法访问/usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar
什么这是什么意思,我怎样才能摆脱它? :S
I copied the text of my program to another computer, but there is some problem with importing sun.audio.AudioPlayer
class. The compiler underlines the importing string and when I place mouse over it, there is this text, which I can't quite understand:
Access restriction: The type
AudioPlayer
is not accessible due to restriction on required library/usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar
What does that mean, and how can I get rid of it? :S
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可以通过更改 Eclipse IDE 内的设置来删除此错误消息。使用以下任意路径打开如下所示的对话框。
Windows(Command + ,)->首选项-> Java->编译器->错误/警告
项目(Command + I)->属性-> Java编译器->错误/警告
在对话框中的“已弃用和受限 API”部分下找到“禁止引用(访问规则)”选项。该选项决定如何处理 Eclipse 内部定义的访问规则。默认情况下,它设置为“Error”,这会导致 Eclipse 抱怨对任何受限类的引用。选择任何其他选项(警告或忽略)将删除这些错误消息。
“警告”或“忽略”选项只会隐藏项目中的潜在问题,因为允许项目使用任何忽略预定义访问规则的类。要彻底解决此问题,请分析项目并找到受限类的使用情况并采取必要的操作(删除这些引用或访问规则)。
This error message can be removed by changing a setting inside Eclipse IDE. Open up the dialog box shown below, using any of the following paths.
Windows(Command + ,) -> Preferences -> Java -> Compiler -> Errors/Warnings
Project(Command + I) -> Properties -> Java Compiler -> Errors/Warnings
Locate the “Forbidden reference (access rules)” option under “Deprecated and restricted API” section in the dialog box. This option decides how to handle access rules defined inside Eclipse. By default it is set to “Error” which causes Eclipse to complain about references to any restricted classes. Choosing any other option (Warning or Ignore) will remove these error messages.
“Warning” or “Ignore” options will only hide the potential issue in the project, by allowing the project to use any classes ignoring predefined access rules. To completely resolve this issue, analyze the project and located the use of restricted classes and take necessary actions (either remove those references or access rules).
听起来你需要配置你的 Eclipse 以使用 openjdk,如所述 这里
Sounds like you need to configure your eclipse to use openjdk as described here
或者只是删除/重新添加相同的 JDK。为我工作。
Or just remove / reeadd same JDK. Worked for me.