简体   繁体   English

在Eclipse Java项目中使用sun。*类

[英]Use sun.* classes in Eclipse Java project

I was sent some Java code that uses classes in the sun.awt.shell package, which is not part of the JDK public API, so Eclipse will not compile the project: sun.awt.shell一些使用sun.awt.shell包中的类的Java代码,它不是JDK公共API的一部分,所以Eclipse不会编译项目:

Access restriction: The method getIcon(boolean) from the type ShellFolder is not accessible due to restriction on required library /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/classes.jar 访问限制:由于对所需库/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/classes.jar的限制,无法访问ShellFolder类型的方法getIcon(boolean)

While I agree with the sentiment, can I coerce Eclipse to compile it anyway? 虽然我同意这种观点,但我还能强迫Eclipse编译吗?

Window -> Preferences -> Java -> Compiler -> Errors/Warnings ,找到“Deprecated and restricted API section”,并将“Forbidden reference”设置从Error更改为Warning或Ignore。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM