Java tutorial · Intermediate · 15 min
Migrating a banking application from Java 8 to Java 25
Many back-office applications still run on Java 8. Frameworks have dropped it (Spring Boot 3 requires Java 17), fixes are getting scarce, and an unsupported version is a risk DORA expects you to address. Java 25, the LTS release from September 2025, is the right target. Here is the method we follow.
Step 1. Take stock before touching the code
Two tools shipped with the JDK find most blockers. Run them with JDK 25 against the current JARs:
# Internal JDK APIs used by the application and its dependencies
jdeps --jdk-internals --multi-release 25 --class-path 'lib/*' app.jar
# Deprecated APIs, and above all those removed since Java 8
jdeprscan --release 25 --class-path 'lib/*' app.jar
Add the list of dependencies and their versions (gradlew dependencies or mvn dependency:tree): an old version of Lombok, Mockito, Byte Buddy, Hibernate or a JDBC driver is enough to block the migration. Also note the JVM options in the start scripts.
Step 2. Upgrade the build
Use a recent build tool (Gradle 9.1 or later for Java 25, or a recent maven-compiler-plugin), then declare the target:
build.gradle
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}
With Maven, <maven.compiler.release>25</maven.compiler.release>. The release option also checks that you do not call APIs missing from the target version.
Step 3. Replace the removed Java EE modules
Java 11 removed JAXB, JAX-WS, JAF, JTA and CORBA from the JDK (JEP 320). Banking applications that produce or read XML (SWIFT, reporting feeds) are almost always affected: ClassNotFoundException: javax.xml.bind.JAXBContext. Add the implementations as dependencies:
dependencies {
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.2'
runtimeOnly 'org.glassfish.jaxb:jaxb-runtime:4.0.5'
}
These versions use the jakarta.xml.bind namespace: a good moment to move to Jakarta EE (step 5).
Step 4. Stop reaching into the JDK's internals
Since Java 17 (JEP 403), internal APIs are closed: reflective access to sun.misc or to private fields of java.lang throws InaccessibleObjectException. The real fix is to upgrade the offending library. In the meantime, open only what is needed and log it as debt:
java --add-opens java.base/java.lang=ALL-UNNAMED -jar app.jar
Step 5. Let OpenRewrite do the repetitive work
OpenRewrite applies migration recipes across the whole code base: removed APIs, javax.* to jakarta.*, Spring Boot upgrades, JUnit 4 to JUnit 5.
build.gradle
plugins {
id 'org.openrewrite.rewrite' version 'X.Y.Z' // latest version on plugins.gradle.org
}
rewrite {
activeRecipe('org.openrewrite.java.migrate.UpgradeToJava21')
activeRecipe('org.openrewrite.java.migrate.jakarta.JakartaEE10')
}
dependencies {
rewrite 'org.openrewrite.recipe:rewrite-migrate-java:latest.release'
}
./gradlew rewriteDryRun # produces a diff to review
./gradlew rewriteRun # applies the changes
Review the diff like a code review: the recipes cover the bulk, not the special cases. The catalogue also has recipes for later Java versions and for Spring Boot 3.
Step 6. Silent changes, the most dangerous ones
Some changes do not break the build but change the results. These are the ones that cause production incidents:
- UTF-8 by default (Java 18, JEP 400):
new FileReader(f)orgetBytes()without a charset used to read Windows-1252 on a Windows server; they now read UTF-8. Files from a mainframe or an old package come out with corrupted accents. Always state the charset. - CLDR locale data (Java 9, JEP 252): number and date formats changed. In French, the thousands separator becomes a narrow no-break space (U+202F): a report or CSV read by another system may no longer be recognised. The old compatibility mode was removed in Java 23.
- Removed JVM options: the CMS garbage collector (removed in Java 14) and other old options stop the JVM from starting. Clean up the scripts.
- Security Manager: permanently disabled since Java 24 (JEP 486).
System.setSecurityManagerthrows an exception.
Step 7. Prove that nothing changed
Unit tests are not enough. Before the migration, freeze reference outputs on real anonymised data: reports, reporting files, calculation results. Replay them on the new version and compare byte for byte; every difference is either explained or fixed.
@Test
void reportIsIdenticalBeforeAndAfterMigration() throws IOException {
Path expected = Path.of("src/test/resources/reference/report-2026-10.csv");
Path produced = report.generate(LocalDate.of(2026, 10, 31));
assertThat(produced).hasSameTextualContentAs(expected, StandardCharsets.UTF_8);
}
Then: make the most of Java 25
- Records, text blocks and pattern-matching
switchsimplify business objects and rules. - Virtual threads raise the throughput of services that wait on databases and APIs.
- Compact object headers (JEP 519, option
-XX:+UseCompactObjectHeaders) reduce the memory footprint: measure it on your workload.
Our advice: migrate in technical stages (build, dependencies, code, runtime), but ship straight to the latest LTS. Going through Java 11 and then 17 multiplies test campaigns for no benefit.
What would your migration cost?
Our legacy diagnostic measures, within days, the gap between your applications and a supported version: dependencies, removed APIs, known vulnerabilities, estimated effort.