Cannot access 'java.io.Serializable' which is a supertype of 'kotlin.String'. Check your module classpath for missing or conflicting dependencies

Viewed 9043

I have a new Kotlin project in Eclipse (I installed the kotlin plugin). However this code:

   val a: Int = 10000
   println("Your Int Value is "+a);

causes this error:

ERROR: Cannot access 'java.io.Serializable' which is a supertype of 'kotlin.String'. Check your module classpath for missing or conflicting dependencies.

What is the source of this error? How can I fix it?

I have seen the other posts on stackoverflow but they all talk about intellij and not Eclipse.

2 Answers

I got this error while using kotlin in eclipse. In my system, JDK was not installed previously. I installed JDK 15 in the PC and set the path in kotlin plugin settings in eclipse (path: Window -> preferences -> Kotlin -> Compiler -> JDK Home)

IntelliJ user here.

In my case, my project settings were (somehow) changed to reference a Java SDK at a path that doesn't exist on my system (hence the inability to find various Java classes).

I fixed this by:

  1. Opening the project/module settings through File -> Project Structure
  2. In the Project Structure dialog, find the Platform Settings section and click on SDKs.
  3. For each JDK entry, either remove or fix the entries that don't show any content in the Classpath tab.
Related