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.
-
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
-
-
Set the
JAVA_HOME
for your current shell to JDK 8export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
-
In the same shell, run
`mvn clean`
-
In the same shell, run the actual Maven build, which will now be done under Java 8 and should work 🤞