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

pez :

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!

Mark Bramnik :

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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=114435&siteId=1