软件包sun.awt不存在 [英] package sun.awt does not exist
本文介绍了软件包sun.awt不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用ant
进行编译时,可以调用sun.awt.AppContext
,但是使用IntelliJ编译的相同代码无法使用AdoptOpenJDK11.
When compiling with ant
, calls to sun.awt.AppContext
work, however the same code compiled with IntelliJ fails using AdoptOpenJDK11.
-
sun.awt.AppContext
与 Oracle JDK8 配合使用IntelliJ
带有 AdoptOpenJDK11 的 -
sun.awt.AppContext
不适用于IntelliJ
sun.awt.AppContext
with Oracle JDK8 works with IntelliJsun.awt.AppContext
with AdoptOpenJDK11 does NOT work with IntelliJ
尽管Sun/Oracle已发出了一段时间警告关于避免使用sun.*
软件包,有 Java中某些仍需要它们的功能(错误?)和陌生人,命令行似乎很开心.
Although Sun/Oracle has warned for a while about avoiding the sun.*
packages, there are certain features (bugs?) in Java that still require them and stranger, the command line seems happy.
示例代码:
package test;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import sun.awt.AppContext;
public class Main {
public static void main(String[] args) {
//Update printer list in CUPS immediately
AppContext.getAppContext().put(PrintServiceLookup.class.getDeclaredClasses()[0], null);
PrintService[] printers = PrintServiceLookup.lookupPrintServices(null, null);
for (PrintService p : printers) {
System.out.println(p.getName());
}
}
}
如何配置IntelliJ使其表现得像ant
并允许访问sun.awt.*
软件包?
How does one configure IntelliJ to behave like ant
and allow access to sun.awt.*
packages?
推荐答案
禁用使用'--release'选项... :
这篇关于软件包sun.awt不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文