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

14,289

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.

Share:
14,289
pez
Author by

pez

Updated on June 09, 2022

Comments

  • pez
    pez almost 2 years

    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!