Java Runtime Error while building using ./your_program.sh

I’m getting this error while trying to run $./your_program.sh locally.

Error: LinkageError occurred while loading main class Main
	java.lang.UnsupportedClassVersionError: Main has been compiled by a more recent version of the Java Runtime (class file version 67.0), this version of the Java Runtime only recognizes class file versions up to 66.0

Any idea how to fix this? It’s forcing me to test it out by running

codecrafters test

more often

Hi @skullers, it looks like a JDK version mismatch.

Could you run java -version and share the output?

Hi @andy1li , here it is:

java version "22.0.1" 2024-04-16
Java(TM) SE Runtime Environment (build 22.0.1+8-16)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)

Upgrading your JDK to version 23 should resolve this issue.