Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java project in Eclipse: The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files

Tags:

java

eclipse

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.

like image 606
Blue Diamond Avatar asked Aug 06 '13 08:08

Blue Diamond


People also ask

How do I clean my Eclipse project?

In Project->Clean I select "Clean projects selected below", select my project(s) and check "Start a build immediately" with "Build only selected projects". Then go to Window->Preferences->General->Keys, search "Build clean" and enter my own binding for this command. For example, Ctrl + D .

How do I open build path in eclipse?

In Eclipse select the web project and right-click Build Path > Configure Build Path. This will display the Java Build Path window.


2 Answers

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 :-)

like image 94
Gyro Gearless Avatar answered Oct 06 '22 19:10

Gyro Gearless


The following steps could help:

  1. Right-click on project » Properties » Java Build Path
  2. Select Libraries tab
  3. Find the JRE System Library and remove it
  4. Click Add Library... button at right side » Add the JRE System Library (Workspace default JRE)
like image 267
Ripon Al Wasim Avatar answered Oct 06 '22 19:10

Ripon Al Wasim