eclipse 3.4.0 ganymede The type java.lang.object "cannot be resolved" "Cannot find the class file" "refers to the missing type"
Problem:
Opened eclipse, it needed to do a full workspace build (probably because ant scripts have updated class files and it needs to refresh). Random classes in the project now no longer compile. Examples of the errors being reported:
Description | Resource | Path | Location | Type |
---|---|---|---|---|
The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files | MyClass.java | MyProject/src/com/example | line 1 | Java Problem |
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 | MyProject | Unknown | Java Problem | |
The method myMethod(SomeClass) from the type MyOtherClass refers to the missing type (insert java type here: InputStream|File|Vector|IOException|etc) | MyOtherClass.java | MyProject/src/com/example | line 123 | Java Problem |
Solution:
It sounds like this has been a known issue (Bug )that was resolved in 3.0 ... someone has commented that it's occurring for them in 3.4 as well.
In the mean time, the work around is to remove the JRE System Library from the project and then add it back again.
Here are the steps:
- Go to properties of project with the build error (right click > Properties)
- View the "Libraries" tab in the "Build Path" section
- Find the "JRE System Library" in the list (if this is missing then this error message is not an eclipse bug but a mis-configured project)
- Remove the "JRE System Library"
- Hit "Add Library ...", Select "JRE System Library" and add the appropriate JRE for the project (eg. 'Workspace default JRE')
- Hit "Finish" in the library selection and "OK" in the project properties and then wait for the re-build of the project
- Hopefully the error will be resolved ...