3

I surprised, because i was able to checkout and run a Kotlin project from Github without this error, and now get get this Java-Error

Unresolved reference: java

I using

  • kotlinc-jvm 1.3.60 (JRE 11.0.4+10-b520.11),
  • IDEA 2019.3,
  • Kernel: 5.3.15-1-MANJARO x86_64 bits: 64 compiler: gcc v: 9.2.0 Desktop: Xfce 4.14.1 Distro: Manjaro Linux

i tried hit Alt+Enter. IDE manual says: "Alt+Enter: Show intention actions and quick-fixes."

This is my File-Name:

/home/me/IdeaProjects/KeyEvent-Reader-Demo/src/Test.kt

Same Error i found here: https://discuss.kotlinlang.org/t/kotlin-unresolved-reference-java/6734

7
  • Do you have JDK configured for project/module in "Project Structure"? Commented Dec 13, 2019 at 11:05
  • hmm. i see no misconfiguration here: imgur.com/JJ3be9q.png , imgur.com/SNJ4yuJ.png Commented Dec 13, 2019 at 11:15
  • and in imgur.com/yvth5Ik.png i dont see misconfiguration Commented Dec 13, 2019 at 12:50
  • 2
    Looks like classpath for JDK 11 is empty. Please try to recreate JDK item in IDE. Commented Dec 16, 2019 at 9:14
  • 1
    Does it help to remove this variable? Commented Dec 19, 2019 at 9:07

2 Answers 2

10

I had the same problem, the @y.bedrov's suggestion helps me.

The issue is that the Classpath is empty (under Project Structure -> Platform Settings -> SDKs -> <choose active SDK> -> Classpath)

To fix this, you can recreate the SDK:

  1. Project Structure -> Platform SDKs -> <choose active SDK> -> "-"
  2. Project Structure -> Platform SDKs -> "+" -> <choose target SDK location>
Sign up to request clarification or add additional context in comments.

1 Comment

This suprisingly worked. FYI, I did this with a JDK11 openjdk build on windows.
2

This was definitely some IntelliJ peoblem for me. I could solve the issue by stupidly deleting the "problematic" class and creating it again:

  • Delete class and imports that refer to it in project
  • Create the same class and adding imports

What generally people also suggest when having similar problem (but didn't help in my case):

  • Restart IDE (File -> Invalidate caches... )
  • Check Platform SDKs as mentioned in another answer here
  • IntelliJ -> PReferances -> Build, Execution, Deployment -> Make sure that Kotlin Compiler and Java Compiler match in versions.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.