That was an annoying configuration where my project was using JDK 11 but I did not see that my Gradle settings were using JDK 16 and that kept giving me the error:
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
After I removed JDK 16 from my project, it pointed me to the fact that Gradle had no JDK configured. Hint.
Now that everything is using JDK 11, life is beautiful again in my IDE.
I have started to use SDKMan to simplify my life with installing and updating many software that I use regurlarly. Java is one of them. It is the simplest thing to install java with sdk man:
sdk i java 11.0.8.hs-adpt
As simple as that.
I can just use Java 11 from that point on. You can also install Java 8 and switch between both. Convenient when you have to maintain older software.
If I want to update to a new release, I simply have to type:
sdk ug java
Can it really get any easier?
I use the SDKMan on my linux laptop as well and it easily works on both.
I also manage gradle, spring-boot and spark with SDKMan so most of my coding tools are kept up to date with the same tool.
It took longer than I want to admit to have a simple Koltin application build this morning. The build.gradle.kts needed a bit of tweaking to get a simple 3 class application with a single test to properly build.
Here is the content of the build.gradle.kts:
kotlin("jvm") version "1.4.10"
val compileKotlin: KotlinCompile by tasks
jvmTarget = "11"
val compileTestKotlin: KotlinCompile by tasks
jvmTarget = "11"
Decided to try to learn Java 8 and Spring 5 but the first commit is using Spring Boot 2.0.0.BUILD-SNAPSHOT.
I got a working controller and everything is building with Gradle 3.3.