简体   繁体   English

尝试在 IntelliJ Idea 中运行 Kotlin 项目但出现错误错误

[英]Attempting To Run Kotlin Project In IntelliJ Idea But Getting Bug Error

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.我正在尝试开始学习 Kotlin,并且我已经安装了 JetBrains 的 IntelliJ Idea,我真的很喜欢 IDE 的布局,所以我真的不想改变它。

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...我知道这不是代码,而且由于我对 IntelliJ Idea 或 Kotlin 不是很熟悉,我不知道从哪里开始查找错误或从哪里修复它......


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!!!有人请帮忙!!!

I created instruction:我创建了指令:

  • Install JDK (for example Oracle JDK 14 )安装 JDK(例如Oracle JDK 14

  • Open project folder with build.gradle and settings.gradle in Idea在 Idea 中使用build.gradlesettings.gradle打开项目文件夹

  • Add JDK to project: press F4 on left Project Tool -> SDk -> Add -> Apply将JDK添加到项目中:在左侧Project Tool上按F4 -> SDk -> Add -> Apply

    开发工具包

  • Set new SDK to project: press F4 on left Project Tool -> Project -> Project SDK -> Set new SDK -> OK设置新的F4到项目:在左侧Project Tool -> Project -> Project SDK -> Set new SDK -> OK

    为项目设置 SDK

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

    为 Gradle 设置 SDK

  • Create new directory src/main/kotlin/main.kt with code使用代码创建新目录src/main/kotlin/main.kt

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 main.kt到编辑器中的 main.kt 并按Ctrl + Shift + F10 ,您必须在控制台中看到您的 JDK 版本,例如: Using JDK: 14.0.2

Take a look sample project样例项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试在IntelliJ IDEA中运行Kotlin脚本 - Trying to run Kotlin script in IntelliJ IDEA 无法在IntelliJ Idea中运行或调试Kotlin - Cant Run or Debug Kotlin In IntelliJ Idea 如何在Intellij Idea中运行Kotlin函数 - How to run Kotlin function in Intellij Idea IntelliJ IDEA - Kotlin 项目中未加载 Kotlin Maven 依赖项 - IntelliJ IDEA - Kotlin Maven Dependency Not Loaded in Kotlin Project IntelliJ IDEA Ultimate 2018.3 认为我的 Java 9 项目是 Kotlin 项目 - IntelliJ IDEA Ultimate 2018.3 thinks my Java 9 Project is a Kotlin Project 当我尝试在 intellij idea 社区版本 2021.2 中运行我的第一个 kotlin 代码时出现错误 - I get an error when i try to run my first kotlin code in intellij idea community version 2021.2 尝试在 Vscode 中运行 kotlin 时出错 - Error when attempting to run kotlin in Vscode Intellij Idea:禁用项目资源管理器中的kotlin文件扩展 - Intellij Idea: Disable kotlin file expansion in project explorer 如何在 Android Studio 和 IntelliJ IDEA 的项目中共享 Kotlin 格式约定? - How to share Kotlin formatting conventions in project for Android Studio and IntelliJ IDEA? TornadoFX _ Kotlin _ IntelliJ IDEA:由于我在项目中使用 openJDK 8,我怎么可能得到“未解决的参考:javafx”? - TornadoFX _ Kotlin _ IntelliJ IDEA: How is it possible that I am getting an “Unresolved reference: javafx” since I am using openJDK 8 in my project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM