How do I transition from Java 8 to Java 17/21 effectively for a legacy monolith?
We’ve been stuck on Java 8 for years, and the tech debt is starting to hurt our recruitment and performance. We want to jump straight to Java 21 (LTS). What are the biggest breaking changes we should prepare for regarding the module system (Jigsaw) and removed APIs like JAXB that used to be in the JDK?
2025-09-20 in Software Development by Karen Scott
| 14220 Views
All answers to this question.
Moving from 8 to 21 is a huge leap but definitely worth it for the performance alone. The biggest shock will be the removal of the "Java EE" modules (JAXB, JTA, etc.) from the JDK. You now have to include these as explicit Maven/Gradle dependencies using the jakarta.* coordinates. Regarding the module system, you don't actually have to modularize your own code; you can keep everything on the "unnamed module" (classpath), but you will likely run into "InaccessibleObjectException" due to stronger encapsulation. You'll need to use the --add-opens JVM flag to allow libraries like Spring or Hibernate to access internal JDK fields until those libraries are updated.
Answered 2025-01-12 by Betty Adams
Did you find that any specific third-party libraries became totally incompatible during the jump? We use some very old XML processing jars and I'm scared they'll break.
Answered 2025-03-05 by Charles Green
-
Charles, old XML libraries are a common pain point. Many of them rely on internal Sun/Oracle classes that are now completely hidden or removed. Before you migrate, run the jdeps tool on your jars; it will tell you exactly which internal APIs your dependencies are using. In our case, we had to find modern alternatives for three different libraries because the originals hadn't been updated since 2015 and simply wouldn't start on Java 17+. It’s a good time to audit your dependency tree and remove the "zombie" libraries that are no longer maintained.
Commented 2025-03-25 by Anthony Baker
Don't forget to update your build tools first! Old versions of Maven or Gradle won't even recognize the Java 21 bytecode or the newer compiler flags.
Answered 2025-04-10 by Helen Nelson
-
Spot on, Helen. We had to upgrade to Gradle 8.x before we could even attempt a successful compile. It's the first step in the whole process.
Commented 2025-04-15 by Karen Scott
Write a Comment
Your email address will not be published. Required fields are marked (*)

