Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading to Java 11 from Java 8 - 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?

Any ideas on what's up?

Thanks!

like image 359
pez Avatar asked Jan 02 '23 17:01

pez


1 Answers

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.

like image 82
Mark Bramnik Avatar answered Jan 05 '23 15:01

Mark Bramnik