Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The type java.lang.object cannot be resolved - Eclipse buildpath not working

I'm having a problem with Eclipse on by Mac OSX Mountain Lion. I have recently installed Android SDK and in my java projects I get the following message:

The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files

Reading about this issue, it would seem that I do not have a valid JRE defined in the build path of my project. Checking the project's build path with Properties > Java Build Path > Libraries I see that The JRE System Library has a red cross next to it. However when I click Add Library... > JRE System Library I get the message:

An error has occured. See error log for more details. java.lang.NullPointerException

I then try clicking Eclipse > Preferences > Java > Installed JREs and see an empty list. I try to Add... a Standard VM but I cannot find the location of my JRE. /Library/Java/JavaVirtualMachines/ is empty and /System/Library/Frameworks/JavaVM.framework does not exist.

Does anyone know how I might fix this problem?

like image 201
user2260199 Avatar asked Aug 16 '14 05:08

user2260199


People also ask

How do I clean my Eclipse project?

To clean projects in Eclipse IDE: Go to Menu option –> Select Project –> click Clean… Note: The same can also be achieved by clicking CTRL + S (save) simultaneously in Eclipse IDE.

Why is my Eclipse project not resolving Java object cannot be resolved?

with Eclipse The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files This is the nice error message I got from Eclipse after the CVS checkout of a project. This error is kind of annoying because Object is the base of almost all Java entities, without it it’s impossible to create any Java class.

How to set JRE build path in Eclipse?

However I have set the path as C:\Program Files\Java\jdk1.6.0_41 from eclipse Kepler toolbar->windows->preferences->java->installed jre project->build path-> configure build path -> java build path -> libraries tab -> select JRE system library and click edit button -> If alternative JRE is selected choose workspace default JRE.

How do I fix eclipse error in Java?

sometimes this error happened after updating JAVA. if so go to eclipse.ini file in the same folder where eclipse existed. then change the line under -vm keyward to the new path of jre/bin folder to get the path go to programfiles -> java -> jre latest version -> bin folder copy the path and replace in line under -vm keyword.

How to fix the JRE library not working in Eclipse?

Close the project and reopen it. Clean the project (It will rebuild the buildpath hence reconfiguring with the JDK libraries) Delete and Re-import the project and if necessary do the above steps again. Same here. Bizarre Eclipse bug. The As the link says, removing the JRE library from project's classpath and re-add it fix the problem.


2 Answers

This worked for me :

  • Right click on your project -> Build Path -> Configure Build Path
  • Go to 'Libraries' tab
  • Click on 'Add Library' -> JRE System Library -> Next -> Workspace default JRE (or you can add Alternate JRE) -> Finish
like image 157
jyothiv Avatar answered Sep 27 '22 21:09

jyothiv


Right Button in the Project: Build Path >> Configure Build Path >> Click JRE System Library >> Remove

Then click: Add Library >> JRE System Library >> Next >> Installed JREs >> Select JRE >> Ok >> Finish >> Apply

like image 29
JamesB Avatar answered Sep 27 '22 21:09

JamesB