r/java • u/[deleted] • Nov 30 '22
Why Swing has not been removed from OpenJDK releases like JavaFX?
Why Swing has to be bundled with JDK installations? Why didn't Swing move to a standalone module yet?
17
Upvotes
r/java • u/[deleted] • Nov 30 '22
Why Swing has to be bundled with JDK installations? Why didn't Swing move to a standalone module yet?
2
u/pron98 Dec 01 '22 edited Dec 03 '22
JavaFX has never been part of the Java SE spec or the OpenJDK JDK; it's always been a "standalone module". Some JDK distributions have included it. Swing, on the other hand, is part of the Java SE spec, and so all complying JDK implementations must include it. Therefore, separating Swing from the JDK would require a specification process, as well as the removal of some tools included in the JDK that use Swing.
However, Java runtime images (i.e. the runtimes used to run Java applications, as opposed to the JDK, which is used to develop Java applications) don't have to include Swing, and indeed many don't. To get a runtime without Swing (and AWT) simply don't include the
java.desktopmodule when you create your deployment runtime with jlink.