I'm trying to compile a Java program using gradlew
, but I am stuck on the error:
$ ./gradlew core:compileJava
No Android SDK found. Skipping Android module.
> Configure project :
Compiling with build: 'custom build'
> Configure project :desktop
Scheduling sprite packing.
> Task :core:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':core:compileJava'.
> error: release version 8 not supported
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
I've tried --info
and --debug
but I can't tell what's causing the error. It sounds as if it's trying to compile with Java 8, but I have no clue how that's happening. The only JDKs I have installed are java-17-openjdk-17.0.9.0.9-1.fc39.x86_64
and java-latest-openjdk-21.0.1.0.12-1.rolling.fc39.x86_64
.
Where and why am I (apparently) getting Java 8 from, and how can I tell what actual command is causing the error?
Okay, I figured this out myself, but I'm going to post anyway because it confused the ever-loving snot out of me, and I couldn't find any useful information elsewhere. Also, this doesn't answer the "how do I figure out why this is broken?" part of my Question, and I'd still appreciate that information.
It turns out the problem is that java
is coming from java-17-openjdk
, but javac
was coming from java-latest-openjdk-devel
... and, because gradlew
was in places invoking JDK 17 specifically, who knows what javac
it was actually trying to use.
Anyway, the reason my system was set up like that is because tons of things depend on JDK 17, whereas java-latest-openjdk-devel
is the obvious thing to install when one wants to build things that use Java.
So, the moral of the story is, check that java --version
and javac --version
report the same thing, and in particular, in case of weird gradlew
failures, make sure to know what java
it's using and that the corresponding javac
is installed.