Wouter
Wouter

Reputation: 2653

Eclipse: "The import java.io cannot be resolved"

I have several Android projects in Eclipse, and all is fine, except one (a library) that can not resolve any imports.

The java.io imports do resolve fine in other Android projects in the same workspace, and previously (I haven't used it for over a year) this library worked fine, too.

Any ideas?

Upvotes: 35

Views: 131697

Answers (5)

Tim Lammarsch
Tim Lammarsch

Reputation: 199

I just ran into this problem with Eclipse 2022-6 and java-17-openjdk-amd64. I just appeared during editing in another file, the same code had worked before.

For me, all settings were correct and none of the above tricks worked. What I then did was completely removing the import command import java.io.Closeable;, saving the file, adding the same import command back at the same place, and saving again. The error disappeared.

Upvotes: 0

Venkat
Venkat

Reputation: 71

I was missing the JRE Systems Library in my Project Tree. And navigating to Projects' Build Path and 'Add(ing) Library' worked!

Upvotes: 0

Swastik Raj Ghosh
Swastik Raj Ghosh

Reputation: 668

I am using Maven an this is what I did to re-solve -->

  1. Right click on project
  2. Maven -> Update Project. Make sure you choose 'Force update of Snapshots/Releases'.
  3. Also check the 'clean project', 'update project conf from pom' and 'refresh workspace resource options' and click ok.

Upvotes: 9

1218985
1218985

Reputation: 8032

Check two things

Eclipse preferences

  1. Check your Eclipse preferences: Java -> Installed JREs
  2. The one that you're using should be marked and it should be a JDK not just a JRE.

Project build path

  1. Also check your project's build path: Right click on the project -> Properties -> Java Build Path
  2. Check in the libraries folder whether the JRE System Library is present and ...
  3. If not add it using Add library -> JRE System Library and then select the correct one (from an installed JDK).

Upvotes: 91

G. Werner
G. Werner

Reputation: 309

The following worked for me:

  • Close the project and reopen it.

OR

  • Clean the project ( = rebuilds the buildpath and thereby reconfigures the JDK libraries).

Upvotes: 2

Related Questions