logo

Java - Deprecated

Last Updated: 2022-04-25

Java has a huge ecosystem, but not everything is worth learning. Here's a growing list of noises that you could safely ignore, or things you should mindfully avoid.

Some of these are clearly labeled as "Deprecated", or even removed from JDK after a certain release; some are still widely used but we have good reasons not to.

Deprecated Modules/Packages/Functions

  • Java Applet: deprecated since Java 9 and removed from Java 11.
  • JSP: an ancient way to build web pages.
  • Nashorn: that JavaScript engine, deprecated since Java 11. Reason: it's hard to keep up with the pace of the fast evolving JavaScript/ECMAScript.
  • JavaFX: spinoff from JDK since Java 11.
  • java.lang.Object.finalize() is deprecated since Java 9

Java EE and Corba packages removed from Java SE

Removed in Java 11 from SE, as part of JEP 320.

  • java.xml.ws (JAX-WS, plus the related technologies SAAJ and Web Services Metadata)
  • java.xml.bind (JAXB)
  • java.activation (JAF)
  • java.xml.ws.annotation (Common Annotations)
  • java.corba (CORBA)
  • java.transaction (JTA)
  • java.se.ee (Aggregator module for the six modules above)
  • jdk.xml.ws (Tools for JAX-WS)
  • jdk.xml.bind (Tools for JAXB)

To check out the current JDK modules(after Java 9):

$ java --list-modules

Classes Not Deprecated But Have Better Alternatives

  • Date and Calendar class should be avoided after the new java.time package in Java 8.
  • prefer Executor over working directly on Thread
  • SortedSet and SortedMap replaced by NavigableSet and NavigableMap in Java 6.
  • avoid Vector, use ArrayList
  • avoid Stack, use ArrayDeque
  • avoid Hashtable and Dictionary, use LinkedHashMap
  • Enumeration => Iterator

Others

  • prefer composition to inheritance
  • PermGen is replaced by Metaspace