12

I have a brand new install of Intellij 2020.3.3 Community and JDK v16. I booted up Intellij, and made sure to update the Kotlin plugin. I created a new Kotlin project, and have made no changes to it. I attempted to run the Kotlin REPL tool (Tools->Kotlin->Kotlin REPL) and I get the following exception:

"C:\Program Files\Java\jdk-16\bin\java.exe" -Dkotlin.repl.ideMode=true -Dfile.encoding=UTF-8     @C:\Users\---\AppData\Local\Temp\idea_arg_file349852720
exception: java.lang.ExceptionInInitializerError
    at com.intellij.pom.java.LanguageLevel.<clinit>(LanguageLevel.java:25)
    at com.intellij.core.CoreLanguageLevelProjectExtension.<init>    (CoreLanguageLevelProjectExtension.java:26)
    at com.intellij.core.JavaCoreProjectEnvironment.<init>(JavaCoreProjectEnvironment.java:42)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreProjectEnvironment.<init>    (KotlinCoreProjectEnvironment.kt:26)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$ProjectEnvironment.<init>    (KotlinCoreEnvironment.kt:121)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:90)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:76)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:45)
    at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:227)
    at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit$default(CLITool.kt:222)
    at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:214)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt:271)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.kt)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected void     java.util.ResourceBundle.setParent(java.util.ResourceBundle) accessible: module java.base does not "opens     java.util" to unnamed module @55141def
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
    at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
    at com.intellij.util.ReflectionUtil.makeAccessible(ReflectionUtil.java:252)
    at com.intellij.util.ReflectionUtil.getDeclaredMethod(ReflectionUtil.java:269)
    at com.intellij.DynamicBundle.<clinit>(DynamicBundle.java:22)
    ... 17 more

I have attempted to reinstall the JDK/IDE, and cleared the temp folder. Not sure what else to try, both the IDE and language are new to me. Suggestions?

EDIT

Found workaround: I did another uninstall, and downgraded to JDKv8 and the issue isn't present.

kiddagger
  • 331
  • 3
  • 9

6 Answers6

4

I installed IntelliJ IDEA Community Edition 2021.1.3 today and am using JDK-16.0.1 on my linux PC.

This also happened in my case. I went through all the settings at first then I found that I had a Kotlin update. After my update the Kotlin REPL started without any error.

To update the Kotlin plugin go to Settings -> Languages & Frameworks -> Kotlin.

Click the check again button to know if you have any new update. If so, then update it and restart, then see if Kotlin REPL is working or not.

pyknight202
  • 1,415
  • 1
  • 5
  • 22
Uday
  • 91
  • 7
3

I fixed it by using JDK 15 instead of 16.

To use JDK 15 follow these steps:

File -> New -> Project...

-> In «Project SDK» go to «Download JDK» and choose «Version: 15» and click Download.

Then just create your project as always (using JDK 15 following the previous steps).

1

I had the same issue during Java upgrades. i use AdoptOpenJDK 16.0.0.j9-adpt and i fixed it by:

  • Upgrade Gradle version to 7.0-rc-1 (i'm early testing it with Java 16)

  • Updated my Gradle script with the below section:

    compileKotlin {
       kotlinOptions {
          jvmTarget = "15"
       }
    }
    
    compileTestKotlin {
       kotlinOptions {
          jvmTarget = "15"
       }
    }
    

Java 16 still not supported yet in the Enum so i had to place it to 15 for now.

Ahmed Lotfy
  • 1,065
  • 2
  • 15
  • 33
1

In this case, all of the compileOptions, the kotlinOptions, and the GradleJdk have the same version. Like the below picture.

enter image description here

Ahmad Aghazadeh
  • 16,571
  • 12
  • 101
  • 98
0

I downloaded adoptopenjdk version 1.8 after creating a new project, and the issue was resolved

Krutin
  • 1
0

settings -> editor -> plugins -> update kotlin plugin

sam
  • 16
  • 3
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 25 '22 at 15:45