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 67414)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 ...
Thanks this solution worked!
ReplyDeleteI had this exact problem in a new install of Eclipse 3.5 (Galileo).
I followed the steps above and the problem went away.
This is what I think caused the problem in the first place: I installed Eclipse and Subclipse, checked out my project, and then set a new default JDK. I think the JRE System Library didn't pick up the new default JDK... maybe I should have set the new default JDK *before* checking out the project.
Anyway, all fixed, thanks!
The error may occur without changing the JDK.
ReplyDeleteI saw this problem when:
- opening Eclipse
- updating my local CVS repository
Basically, it occurs when a partial build is triggered but it is not systematic.
I managed to solve the problem by:
- changing the position of the JRE in the classpath (it is not necessary to remove it and add it again)
- changing the global JDK in order to trigger a clean rebuild. Any JDK is good enough. It has just to be different from the former one.
I have many projects in my workspace so it can be painful to change the classpaths one by one ;)
J. Le Cren
Great, this solution worked, had been a trouble for few days.
ReplyDeleteThanks a ton, this fixed up a problem I was having with all day!
ReplyDeleteThank you so much.....
ReplyDeleteThe solution is working....in my SAP Netweaver Developer Studio as well....
Thanks, it worked!
ReplyDeletethe solution worked great thank you so much
ReplyDeleteThanks a lot for ur help. It really works.
ReplyDeleteWOW!!!! that worked like magic to me. thank u thank u thank u
ReplyDeleteI got 1 JRE1.6 running fine all the time but suddenly 1 day it has this same error. So, I tried this method and it didn't work. (but i believe it is correct working procedure)
ReplyDeleteSo, I use my old JDK1.4 to run the program and it continue to works again. I believe it is the same error just that the JRE/JDK may corrupted. Download again and reinstall the JRE/JDK may helps.
thanks buddy, ur suggestion worked for me.
ReplyDeleteyes, it worked.
ReplyDeleteThanks this worked! The problem I was facing was the same but the reason was that I moved the project to another workspace manually and then opened eclipse. After adding the JRE library, works again.
ReplyDeleteThank you very much. I just fixed the problem.
ReplyDeleteThanks alot for the guidance. The solution indeed work. I was struggling with it for last one day. Proved to be a great help.
ReplyDeleteThanks solution works like a Charm ............
ReplyDeleteExcellent, thanks!
ReplyDeleteThanks a lot
ReplyDeleteThank you it realy works for me :)
ReplyDeleteI just had the same problem in Eclipse Indigo. But the solution works. Great!
ReplyDeleteThanks this worked for me too
ReplyDeleteThanks this solution worked
ReplyDeleteThank you very much. Just fixed the problem.
ReplyDeletevery helpful, thx!
ReplyDeleteEclipse IDE for Java Developers
ReplyDeleteVersion: Indigo Service Release 1
Build id: 20110916-0149
Reloaded project from disk, no changes made since last working online. TFS was unavailable, received a warning that the project is working offline. One class in the project failed to build with this error.
Libraries tab showed "Android Dependencies" and "Unable to get system library for project". Removed last entry, then added "JRE System Library" and "Android Classpath Container" to get it to work.
Thank you!
ReplyDeleteThank you. I am hoping to resolve some long pending issue on my office laptop tomorrow.
ReplyDeleteThanks very much dude, The solution worked for me.
ReplyDeleteI have been developing in this stable Indigo environment for a long time and just installed VeloEclipse plugin from Marketplace without any issue. On restart I got this error. Removing and readd JRE made it go away. Don't know what I would have done if I didn't find this post.
ReplyDeleteThanks a ton. Worked like a charm.
ReplyDeleteThanks for this resolving!!! It's worked today.
ReplyDeleteThank You, the solution worked.
ReplyDeleteThanks. It works for me :)
ReplyDeleteThanks for this easy and workfull answer. This solution worked for me!
ReplyDeleteWorked for me as well. Thank you
ReplyDeleteI was stuck on it for hours... and this just solved it in a minute.. Can't thank you enough
ReplyDeleteworked for me too thanks for the input
ReplyDeleteThanks a lot.It works for me..:)
ReplyDeleteThanks for the solution..it works for me :)
ReplyDeletethz so much. It works great!!! :)
ReplyDeleteThank you!!!
ReplyDeleteThis is work for me :")
Thank you. :)
ReplyDelete