score:272

Accepted answer

this is an annoying eclipse bug which seems to bite now and then. see http://dev-answers.blogspot.de/2009/06/eclipse-build-errors-javalangobject.html for a possible solution, otherwise try the following;

  • close the project and reopen it.

  • clean the project (it will rebuild the buildpath hence reconfiguring with the jdk libraries)

    or

  • delete and re-import the project and if necessary do the above steps again.

the better cure is to try netbeans instead of eclipse :-)

score:0

happend to me after i've installed some updates in eclipse but forgot to restart afterwards. so maybe restarting eclipse might help.

score:0

however trivial this might be, check your java installation. for me, rt.jar was missing.

i found this after fiddling for half a day with eclipse settings and getting nowhere. desperate, i finally decided to try compiling the project from the command line. i wasn't expecting to see anything wrong since i thought it's an eclipse issue but to my astonishment i saw this:

error occurred during initialization of vm
java/lang/noclassdeffounderror: java/lang/object

i don't know what happened to my java installation and where did rt.jar go. anyway this comes as a reminder to go through the fail checklist and tick all the boxes no matter how unbelievable they are. it would have saved me a lot of time.

score:0

right click on project, select maven -> update project. that should solve the issue.

score:0

in my case it was a big modular project and the 'red x' was showing only in the parent project. i went to the parent project

properties -> built path

a removed the jre library there, just that, no jre library on the parent project anymore.

score:0

none of these solutions worked for me. in my case the problem was that i had some java code producing .java files and i had accidentally created a file called class.java (content doesn't seem to matter). removing the file fixed the problem.

score:0

however i have set the path as c:\program files\java\jdk1.6.0_41 from eclipse kepler toolbar->windows->preferences->java->installed jre

if you have already added jre and still showing error. try follow

right click on your project

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.

this is how my error gone.

score:0

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.

score:0

this error message occurs when a class/java-project is unable to resolve correct jdk libraries. say, in my primary project a, i was getting this error. this project a had a maven dependency for a project b. project b pointed to jdk-11. project a pointed to jdk-9

correction i did : made project also point to jdk-11. it resolved the issue for me

score:0

for gradle users, use eclipse plugin. i'm not using eclipse directly but jdtls on neovim. this solves the issue for me.

build.gradle

plugins {
    id 'java'
    id 'eclipse'
}

then run

gradle cleaneclipse eclipse

score:1

i had same problem in eclipse windows that i couldn't added dependant .class files from the jni. in order resolve the same, i ported all the code to netbeans ide.

can not add all the classes files from the jni/jna folder in eclipse (java, windows 7)

score:1

while we are working with tomcat 6 and jdk 1.8 versions, some of the features will not work and this error you are getting is one. you need to change the jdk version to stable version(preferable jdk 1.6 or jdk 1.8_65) in eclipse to resolve this error.

in eclipse step 1: properties -> java build path -> jre system library(remove) step 2: add -> jre system library -> alternate jre -> installed jre -> add -> standard vm -> (in jre home, place jdk path) -> finish

now clean and check the project

score:1

i got this error because i have installed "eclipse ide for enterprise java developers", i uninstalled this and installed "eclipse ide for java developers". problem solved for me.

score:1

it's working for me after unchecking 'user '--releae option' in eclipse java-compiler

in eclipse step 1: properties -> java complier -> uchecking 'user '--releae option' option -> finish

java version 13.0.1 eclipse version : eclipse ide for enterprise java developers.

score:2

i was facing this issue with play-java application on eclipse after adding a controller, i removed and reinstalled jre through build path and then removed and imported my project which solved this issue automatically. thanks gyro.

score:2

what solved my problem was to

1) install the jdk under directory with no spaces:

c:/java

instead of

c:/program files/java

this is a known issue in windows. i fixed java_home as well

2) i java 7 and java 8 on my laptop. so i defined the jvm using eclipse.ini. this is not a mandatory step if you don't have -vm entry in your eclipse.ini. i updated:

c:/java/jdk1.7.0_79/jre/bin/javaw.exe

instead of:

c:/java/jdk1.7.0_79/bin/javaw.exe

good luck

score:2

i had the similar problem. it was a maven project with the following snippet of pom.xml.

<build>
    <plugins>
        <plugin>
            <groupid>org.apache.maven.plugins</groupid>
            <artifactid>maven-compiler-plugin</artifactid>
            <version>3.8.0</version>
            <configuration>
                <release>9</release>
            </configuration>
        </plugin>
        </plugins>
    </build>

i had to change the following.

<build>
    <plugins>
        <plugin>
            <groupid>org.apache.maven.plugins</groupid>
            <artifactid>maven-compiler-plugin</artifactid>
            <version>3.8.0</version>
            <configuration>
                <release>11</release>
            </configuration>
        </plugin>
        </plugins>
    </build>

if you have already installed jdk 11 and working with java 9 or java 10 as maven compiler, eclipse can not detect. hence change the release to 11 or the actual installed version of jdk.

score:3

another problem could be that the android project build target is not set.

  1. right-click the project
  2. choose properties
  3. click android
  4. tick the appropriate project build target
  5. apply | ok

score:4

right click on project -->show in navigator in navigator view you can see .classpath file, do delete this file and build the project. this worked for me. ps. if you have integrated you eclipse project with some version control like perfoce/svn , then unlinking the project before you delete the .classpath will be helpful.

score:4

no amount of cleaning, closing/reopening the project&ide, removing/adding the jre in build path worked for me.

the solution i found was to remove the project from eclipse (not from disk), remove the project's eclipse files from the disk, and import into eclipse again. that worked.

it is even faster if you are using maven:

  1. close eclipse (no need to remove the project)
  2. run mvn clean eclipse:clean eclipse:eclipse
  3. open eclipse. your project is still present and the problem should be gone.

score:5

none of the other answers worked for me. but doing this did:

  1. right click the project in the package explorer.
  2. source > clean up...
  3. next > finish

when i did this eclipse added an import into one of my classes. i think this occurred because i saved my project with a missing import, probably rushing to get home after work.

score:6

this seems to be an eclipse bug, though restarting eclipse worked great for me, hope this helps somebody else too.

edit: the next time i had this problem the solution above did not work - the problem was that the imported project i had - had the wrong java runtime set - which was not present (i had java 8 in my jre present, but the project imported was set to java 11, so i had to change the project java version to 8. alternative would be to add more jre's in the eclipse preferences - if the project really needs a newer jre to work)

score:8

object class is the base class for all the classes in java, if you are missing this it means you don't have the jdk libs in your buildpath. i don't know much about kepler but you need to make sure it points to a correct jdk for compilation and a correct jre for running your java apps.

however i have set the path as c:\program files\java\jdk1.6.0_41 from eclipse kepler toolbar->windows->preferences->java->installed jre

you are trying to point jdk instead of jre in your preferences. toolbar->windows->preferences->java->installed jre should point to a jre and not jdk.

score:8

have you installed a different version jre after , while using previous version of jre in eclipse .

if not than :

  1. right click on your project -> build path -> configure build path
  2. go to 'libraries' tab
  3. add library -> jre system library -> next -> workspace default jre (or you can choose alternate jre form your system) -> finish

if yes than .

  1. right click on your project -> build path -> configure build path
  2. go to 'libraries' tab
  3. remove previous version
  4. add library -> jre system library -> next -> workspace default jre (or you can choose alternate jre from your system) -> finish

score:13

this happened to me when i imported a java 1.8 project from eclipse luna into eclipse kepler.

  1. right click on project > build path > configure build path...
  2. select the libraries tab, you should see the java 1.8 jre with an error
  3. select the java 1.8 jre and click the remove button
  4. add library... > jre system library > next > workspace default > finish
  5. click ok to close the properties window
  6. go to the project menu > clean... > ok

et voilà, that worked for me.

score:14

here is how i solved it: in java-adt: windows - preference - java - installed jres just add another jre, pointing to the 'jre' folder under your jdk folder. (jre is included in the jdk). make sure you chose the new jre.

score:262

the following steps could help:

  1. right-click on project » properties » java build path
  2. select libraries tab
  3. find the jre system library and remove it
  4. click add library... button at right side » add the jre system library (workspace default jre)

Related Query

More Query from same tag