Can newer JRE versions run Java programs compiled with older JDK versions?

As answered already you are mostly safe and most products and 3rd party libraries will simply work. However there do exist (not so-) rare binary incompatibilities.

These incompatibilities happen where the classes compiled using older JDK fail to run in the newer JVM due to compatibility breaking changes introduced in the JDK itself (e.g. class removal, class/method visibility reduction, method signature changes or package changes) were introduced after the code using JDK has been written and compiled.

For Java 9 and earlier:
Official list of Oracle Java incompatibilities:

  • in Java SE 9 since Java SE 8
  • in Java SE 8 since Java SE 7
  • in Java SE 7 since Java SE 6
  • in Java SE 6 since Java SE 5.0
  • in Java SE 5.0 since Java SE 1.4.2

For Java 9 and later:
Compatibility tool

Packaged with JDK 9 and onwards, there is jdeprscan tool, which verifies the compatibility, lists no longer used APIs within your code and suggests alternatives(!). You can specify the target JDK version (works for JDK 17, 11, 9, 8, 7 and 6) and it will list incompatibilities specific to your target version.

Additional comment in case of libraries:

A reasonable rule of thumb is to use latest stable release version of library for the JRE version your software targets. Obviously you will find many exceptions from this rule, but in general stability of publicly available libraries usually increases with time.

Naturally API compatibility and versioning have to be considered when changing versions of dependencies.

Again most popular dependencies will have web pages where such information should be available.

If however you are using something a bit more obscure, you can discern which JRE were the classes within your dependency compiled for.

Here is a great answer on how to find out class version. You might need to unzip the JAR file first.

Leave a Comment