Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 385
Wouter Avatar asked Mar 14 '13 17:03

Wouter


People also ask

Why Java IO * is imported?

The import statement tells the compiler where to look for the external classes you use in your code. It needs to find them to check that you are using them correctly, calling methods that exist, passing the right arguments to them, etc. If you import java.io.

Does Java IO need to be imported?

Java.IO is standard for Java Input/Output. So in essence you're importing extra Input/Output functionality. The asterisk on the end means you're importing everything in the Java.IO Package.

How do I get to Eclipse preferences?

You can locate a preference page by expanding the nodes of the tree in the left hand side of the dialog box. The filter text box on the left hand side top corner allows you to quickly locate a preference page.


2 Answers

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).
like image 162
1218985 Avatar answered Sep 19 '22 19:09

1218985


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.
like image 37
Swastik Raj Ghosh Avatar answered Sep 22 '22 19:09

Swastik Raj Ghosh