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 ...
42 comments:
Thanks this solution worked!
I 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.
I 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.
Thanks a ton, this fixed up a problem I was having with all day!
Thank you so much.....
The solution is working....in my SAP Netweaver Developer Studio as well....
Thanks, it worked!
the solution worked great thank you so much
Thanks a lot for ur help. It really works.
WOW!!!! that worked like magic to me. thank u thank u thank u
I 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)
So, 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.
yes, it worked.
Thanks 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.
Thank you very much. I just fixed the problem.
Thanks alot for the guidance. The solution indeed work. I was struggling with it for last one day. Proved to be a great help.
Thanks solution works like a Charm ............
Excellent, thanks!
Thanks a lot
Thank you it realy works for me :)
I just had the same problem in Eclipse Indigo. But the solution works. Great!
Thanks this worked for me too
Thanks this solution worked
Thank you very much. Just fixed the problem.
very helpful, thx!
Eclipse IDE for Java Developers
Version: 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!
Thank you. I am hoping to resolve some long pending issue on my office laptop tomorrow.
Thanks very much dude, The solution worked for me.
I 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.
Thanks a ton. Worked like a charm.
Thanks for this resolving!!! It's worked today.
Thank You, the solution worked.
Thanks. It works for me :)
Thanks for this easy and workfull answer. This solution worked for me!
Worked for me as well. Thank you
I was stuck on it for hours... and this just solved it in a minute.. Can't thank you enough
worked for me too thanks for the input
Thanks a lot.It works for me..:)
Thanks for the solution..it works for me :)
thz so much. It works great!!! :)
Thank you!!!
This is work for me :")
Thank you. :)
Post a Comment