rmoff's random ramblings
about talks

UnsupportedClassVersionError: <x> has been compiled by a more recent version of the Java Runtime

Published Jan 21, 2020 by in Maven, Jdk at https://rmoff.net/2020/01/21/unsupportedclassversionerror-x-has-been-compiled-by-a-more-recent-version-of-the-java-runtime/

This article is just for Googlers and my future self encountering this error. Recently I was building a Docker image from the ksqlDB code base, and whilst it built successfully the ksqlDB server process in the Docker container when instantiated failed with a UnsupportedClassVersionError:

java.lang.UnsupportedClassVersionError: javafx/beans/value/ObservableValue has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Here’s how I fixed it, courtesy of help from my colleagues Colin and Tim.

  1. Download JDK 8 ("Java SE") and install it

    • On my Mac I had an existing Java, this article showed how to list them and switch between them

      $ /usr/libexec/java_home -V
      
      Matching Java Virtual Machines (2):
          12.0.2, x86_64:	"OpenJDK 12.0.2"	/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.2.jdk/Contents/Home
          1.8.0_241, x86_64:	"Java SE 8"	/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home
  2. Set the JAVA_HOME for your current shell to JDK 8

    export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
  3. In the same shell, run

    `mvn clean`
  4. In the same shell, run the actual Maven build, which will now be done under Java 8 and should work 🤞


Robin Moffatt

Robin Moffatt works on the DevRel team at Confluent. He likes writing about himself in the third person, eating good breakfasts, and drinking good beer.

Story logo

© 2025