0

My Previous Question + More


I am trying to start learning Kotlin, and I have installed IntelliJ Idea from JetBrains, I really like the layout of the IDE, and so I don't really want to change it.

Whenever I try to run the program, I get the following error:

Could not open init generic class cache for initialization script 'C:\Users\Jacob\AppData\Local\Temp\wrapper_init1.gradle' (C:\Users\Jacob\.gradle\caches\6.6.1\scripts\9x7j38tmeo1ohlyu8452ntfdm).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 60

I know it's not the code, and since I am not very familiar with IntelliJ Idea or Kotlin, I have no idea where to start looking for the error or where to fix it...


Someone said that this question's answers were the solution, but I looked their, tried what it shows, but still found now solution for my situation... When I follow what they say, I get the same error.

Someone please help!!!

Jacob Hornbeck
  • 398
  • 2
  • 19
  • Do you use a JDK 16 in `File | Project Structure | Project | Project SDK` or in `Build, Execution, Deployment | Build Tools | Gradle`? Please try updating the [Gradle to 7.0](https://docs.gradle.org/current/userguide/upgrading_version_6.html) or use a lower JDK to see if it helps. – floating cat Apr 30 '21 at 04:38
  • Thank you! Your comment as well as [Maxim Kochetkov's](https://stackoverflow.com/users/14711501/maxim-kochetkov) answer helped me fix it! – Jacob Hornbeck May 01 '21 at 18:03

1 Answers1

1

I created instruction:

  • Install JDK (for example Oracle JDK 14)

  • Open project folder with build.gradle and settings.gradle in Idea

  • Add JDK to project: press F4 on left Project Tool -> SDk -> Add -> Apply

    SDk

  • Set new SDK to project: press F4 on left Project Tool -> Project -> Project SDK -> Set new SDK -> OK

    Set SDK for Project

  • Set new SDK to Gradle Build Tool: press Ctrl + Alt + S -> Find gradle in search -> Go to Gradle JVM -> Set new SDK -> OK

    Set SDK for Gradle

  • Create new directory src/main/kotlin/main.kt with code

fun main() {
    val jdk = System.getProperty("java.version")
    println("Using JDK: $jdk")
}
  • Go to main.kt in Editor and press Ctrl + Shift + F10 and you must see your JDK version in console like: Using JDK: 14.0.2

Take a look sample project

  • Thank you for these instructions... but it doesn't solve my problem... I think it may be in the run configuration, what do you have for that? – Jacob Hornbeck May 01 '21 at 17:45
  • Okay, nevermind... it actually _does_ solve my problem... as well as the comment that [@floatingcat](https://stackoverflow.com/users/2331527/floating-cat) posted in my question. I had just forgot to change the Gradle one after I had installed one not v16... for some reason that doesn't work with my computer... – Jacob Hornbeck May 01 '21 at 18:02