Java project in Eclipse: The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
I am getting the following error after importing a project in Eclipse:
The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
However, I have set the path as C:\Program Files\Java\jdk1.6.0_41 in Eclipse Kepler, through Window » Preferences » Java » Installed JREs.
This is an annoying Eclipse Bug which seems to bite now and then. See http://dev-answers.blogspot.de/2009/06/eclipse-build-errors-javalangobject.html for a possible solution, otherwise try the following;
-
Close the project and reopen it.
-
Clean the project (It will rebuild the buildpath hence reconfiguring with the JDK libraries)
OR
-
Delete and Re-import the project and if necessary do the above steps again.
The better cure is to try NetBeans instead of Eclipse :-)
The following steps could help:
- Right-click on project » Properties » Java Build Path
- Select Libraries tab
- Find the JRE System Library and remove it
- Click Add Library... button at right side » Add the JRE System Library (Workspace default JRE)
Here is how I solved it: In Java-ADT: Windows - Preference - Java - Installed JREs Just add another JRE, pointing to the 'jre' folder under your JDK folder. (jre is included in the jdk). Make sure you chose the new jre.
This happened to me when I imported a Java 1.8 project from Eclipse Luna into Eclipse Kepler.
- Right click on project > Build path > configure build path...
- Select the Libraries tab, you should see the Java 1.8 jre with an error
- Select the java 1.8 jre and click the Remove button
- Add Library... > JRE System Library > Next > workspace default > Finish
- Click OK to close the properties window
- Go to the project menu > Clean... > OK
Et voilà, that worked for me.