从Java 8升级到Java 11-软件包sun.util不存在 [英] Upgrading to Java 11 from Java 8 - package sun.util does not exist
问题描述
我正在尝试将应用程序从Java 8迁移到Java11.当我尝试在IntelliJ中构建项目时,出现package sun.util does not exist
错误?
I'm trying to migrate an application from Java 8 to Java 11. When I try and build the project in IntelliJ I get a package sun.util does not exist
error?
有什么想法吗?
谢谢!
推荐答案
包com.sun.*
和sun.*
包含内部内容,一般情况下不应被第三方应用程序使用(可能与您的应用程序一样).
Packages com.sun.*
and sun.*
hold internal stuff, and should not be used by thirdparty applications (like yours probably) in general case.
自从Java 9中引入了模块系统以来,现在Oracle即使在编译时也保护"了这些软件包.
Since in java 9 the module system has been introduced, now Oracle "protect" these packages even in compile time.
因此,显而易见的方法是摆脱代码中的这种依赖关系. 他们为什么要保护?因为他们保留更改这些东西的权利,所以正如我所说,它被认为是内部的.
So the obvious way is to get rid of this dependency in your code. Why do they protect? Because they leave the right to themselves to change this stuff, its considered internal as I said.
添加:
You can try (I do not recommend) to apply some "resolution" tools found in this great article (Read "Illegal Access To Internal APIs" chapter), but as the author of this article states, the most straightforward way is to stop using these packages in your code, so consider it as the first bet.
这篇关于从Java 8升级到Java 11-软件包sun.util不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!