Build fails using IDEA, Kotlin Native Gradle and openjdk-14 java version "14.0.1"

Trying to build a Hello World exe file for Windows, using OpenJDK, because I want to minimize anything Oracle. I use IntelliJ IDEA Edu 2020.1 build 14 April.

Creating a new project I choose Kotlin > Native Gradle and openjdk-14.
This creates a new project, but with an error message:
“Invalid Gradle JDK configuration found.”

I go to the Gradle settings and (again) apply the openjdk-14 and click “Reimport Gradle Project”.
It starts building, but ends with the message:
“Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7”

From the Command window I type “gradle -v” and get this output:
Gradle 6.4.1
Build time: 2020-05-15 19:43:40 UTC
Revision: 1a04183c502614b5c80e33d603074e0b4a2777c5
Kotlin: 1.3.71
Groovy: 2.5.10
Ant: Apache Ant™ version 1.10.7 compiled on September 1 2019
JVM: 14.0.1 (Oracle Corporation 14.0.1+7)
OS: Windows 8.1 6.3 amd64

What’s going wrong here?

You need to set proper gradle JDK configuration for IDEA, since it is possible to use custom gradle build. Look at gradle settings for the project. By default it uses project JDK, which must be set as well.

1 Like

Thanks! However, I still get the same error: “Could not initialize class org.codehaus.groovy.classgen.Verifier”.

To no avail, I worked through this help page:

I set openjdk-14 as the Project SDK, restarted IDEA and clicked Reimport Gradle Project.

No idea what I’m doing wrong here.

There’s a strange line in the file

I changed https\:// to https:// but still the same error. Please help.

Gradle 5.5 does not work with jdk-14. You should update to latest gradle (6.4.1 I believe). JDK 14 is supported since 6.3:

1 Like

Thanks again, but I do have Gradle 6.4.1.

IDEA and Gradle were all downloaded and installed in a matter of a week or two. So it’s all up-to-date.

Your gradle wrapper doesn’t use the gradle version installed on your system. It uses the version specified in the wrapper. Try running gradlew --version. This should display the version used by the wrapper. You can change it with gradlew wrapper --gradle-version 6.4.1

That seems very close to the solution of my problem indeed. Thanks! When I look in my IdeaProjects folders I see all kind of different .gradle subfolders and gradle/wrapper folders with different files, like the file in my HelloWorldNative contains something like Apparently this stuff is terribly mismanaged by IntelliJ IDEA. I’m only a few weeks new to this and I don’t have a clue how to get a little HelloWorld working with openJDK-14. Should I wait for an IDEA upgrade maybe?

This is acutally an intended feature of gradle. You every project to specify it’s own gradle version. There is a good chance that if you work on multiple projects, that some of them use gradle versions which aren’t compatible.
Yeaeh, maybe IDEA could be intelligent enough to realize that jdk14 doesn’t work for gradle 5.5.1 or provide you with an easy way to upgrade the gradle version, but I don’t remember this being an issue once gradle is set up properly.
Also in your gradle setting window you can choose which gralde installation to use. Normally I prefer to use the wrapper for the above reasons, but you can point it to your local installation. That way it will allways use the latest version (installed on your system).

1 Like

You can manually switch to using gradle project settings:
In general it is better to update wrapper instead so anyone downloading your project from git would use the same version of the build system.

1 Like