sbt "class file has wrong version 61.0, should be 55.0" in CI
The compiler read a class file targeting a newer bytecode level than the JDK running the build supports. Major version 61 is Java 17 and 55 is Java 11, so a Java 17 dependency cannot be consumed by a build running on Java 11. Align the CI JDK with the dependency.
What this error means
scalac or a downstream step fails with "class file has wrong version 61.0, should be 55.0" (or similar major numbers) while reading a dependency.
[error] error: class file 'Foo.class' has wrong version 61.0, should be 55.0
[error] Please recompile 'Foo.class' with a Java 11 compatible compiler or run with a newer JDKCommon causes
A dependency built for a newer JDK
A library compiled to target Java 17 (major 61) cannot be read by a build running on Java 11 (major 55).
setup-java pinned an older JDK than the build needs
The CI JDK from setup-java is older than the one the dependency or the project targets, causing the version mismatch.
How to fix it
Match the CI JDK to the required bytecode level
- Map the major version in the error (61 is 17, 55 is 11) to a JDK.
- Set
setup-javato a JDK at least as new as the dependency needs. - Re-run so the compiler can read the class files.
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'Target older bytecode if you must stay on Java 11
If the runtime is fixed to Java 11, use a dependency built for Java 11 or set -release 11 so output stays compatible.
scalacOptions ++= Seq("-release", "11")How to prevent it
- Pin the CI JDK with
setup-javato match your dependencies and target. - Use
-releaseto fix the bytecode target explicitly. - Verify dependency JDK targets before upgrading them.