Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use java.* and jdk.* packages

Tags:

java

java-11

I'm using IntelliJ and JDK 11. In the library packages, I see two types of package naming. java.* and jdk.* like shown in the below image:

enter image description here

The jdk.* packages have sun.* packages inside them. What does this mean to developers? Is the general advice to avoid using jdk.*/sun.* as written over here: https://www.oracle.com/java/technologies/faq-sun-packages.html ?

like image 836
user2354302 Avatar asked Feb 01 '26 09:02

user2354302


1 Answers

You are misreading: these are not packages, but modules.

You should use java.* modules and avoid jdk.* because their access/api are not guaranteed to be stable. sun (and com.sun.*) are mostly moved into jdk.* modules.

This all boils down to the JEPs:

The modular structure of the JDK implements the following principles:

  • Standard modules, whose specifications are governed by the JCP, have names starting with the string "java.".

  • All other modules are merely part of the JDK, and have names starting with the string "jdk.".

like image 97
NoDataFound Avatar answered Feb 03 '26 21:02

NoDataFound



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!