Upgrading to Java 11 from Java 8 - package sun.util does not exist

允我心安 提交于 2019-12-12 09:57:44

问题


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?

Any ideas on what's up?

Thanks!


回答1:


Packages com.sun.* and sun.* hold internal stuff, and should not be used by thirdparty applications (like yours probably) in general case.

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.

Addition:

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.



来源:https://stackoverflow.com/questions/52847089/upgrading-to-java-11-from-java-8-package-sun-util-does-not-exist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!