Eclipse Error - Cannot find the class file for java.lang.Object

Eclipse Error - Cannot find the class file for java.lang.Object

The Eclipse might show the error Cannot find the class file for java.lang.Object. This tutorial provides the solution to this error.

April 27, 2020

This tutorial provides the solution to the error thrown by Eclipse for Java projects - The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project.

Solution 1

Try to close the project and re-open it. In several cases, this might solve the issue.

Solution 2

Install the most recent version of Eclipse on your system and open the project using the newly installed JRE. It will resolve the issue.

Solution 3

Your Eclipse build is older than the Java version. In such cases, the eclipse will throw errors in case your project is configured for the newer version of Java as shown in Fig 1.

Eclipse - Java - Version - Error

Fig 1

Now check your Eclipse Version and try to set the older version of Java installed on your system. No need to change the environment variable to resolve this error. Simply update your project to use the older version of Java. Now right-click the project -> Properties -> Java Build Path -> Libraries as shown in Fig 2.

Eclipse - Java Build Path

Fig 2

Now double-click the JRE -> Alternate JRE -> Installed JREs to view the available JREs as shown in Fig 3.

Eclipse - Java - Installed JREs

Fig 3

Click the Add Button -> Standard VM and choose an older JRE. I have selected Java 12 as shown in Fig 4 since my Eclipse version was eclipse-java-2019-06-R-win32-x86_64.

Eclipse - Java - Add JRE

Fig 4

Click the Finish Button and change the project JRE as shown in Fig 5.

Eclipse - Java - Choose JRE

Fig 5

Now click the Apply and Close Button. It will change the default JRE for the Eclipse installation. Now you can also configure the Project JRE as shown in Fig 6.

Eclipse - Java - Choose JRE

Fig 6

Keep the Workspace default JRE selected and click the Finish Button. It will change the project JRE as shown in Fig 7.

Eclipse - Java - Project JRE

Fig 7

Click the Apply and Close Button to apply the changes. It should resolve your error and Eclipse should not complain about the missing class file java.lang.Object.

Summary

This tutorial provided the possible solutions to the Eclipse error Cannot find the class file for java.lang.Object.

Write a Comment
Click the captcha image to get new code.
Discussion Forum by DISQUS