25

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.

1
  • 1
    Probably your project structure does not specify the sdk correctly, go to file->project structure->edit sdk Commented Dec 25, 2020 at 14:01

4 Answers 4

24

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)

Sign up to request clarification or add additional context in comments.

1 Comment

IntelliJ user here. Had the same error with the same solution. Doesn't matter what your IDE is, this is a JDK compilation error :) Hope this helps folks using IntelliJ IDEA, Android Studio and Netbeans too.
24

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.

3 Comments

This worked for me, the best bet is choosing one of the SDK's from the detected JDK's section
can you provide a screenshot? I don't exactly understand what you mean in point 3.
When I installed IntelliJ for the first time, it picked up the Oracle OpenJDK 21 that I had installed in Program Files, but the Classpath tab was empty. I removed it from the File > Project Structure > Platform Settings > SDKs screen, then added it again from the directory, and the Classpath tab got quite a few entries. All the errors like "Cannot access 'java.io.Serializable'" went away after doing that.
10

For me fix was by deleting "project"/.idea/misc.xml file

Comments

-1

Download latest JDK:

  • From Adoptium (Eclipse Temurin) => Install and select it when create new project.

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.