user123456789
user123456789

Reputation: 2004

Eclipse Oxygen - The project was not built since its build path is incomplete

I just installed Eclipse Oxygen and tried to open an existing project into the workbench but I get this error:

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

I tried right clicking on the project - went to Properties - Java Build Path - Libraries - Add Library - JRE System Library and selected Workbench default JRE (jre1.8.0_60).

I then cleaned and rebuilt the project but it then causes more errors to come up like:

ActionBar cannot be resolved to a type
Activity cannot be resolved to a variable
AdapterView cannot be resolved to a type
ArrayAdapter cannot be resolved to a type

Upvotes: 26

Views: 131214

Answers (14)

Glenster
Glenster

Reputation: 1307

I got this problem on Eclipse version 2023-09 (4.29.0)

I knew it was an Eclipse config issue as I didn't change anything and my project was building just before it happened.

I fixed it by going to Project properties and editing the JRE System Library and setting it to another installed JDK, by selecting Alternate JRE. It was actually the same JDK as before but I guess Eclipse thinks I have changed to a different JDK and sorts itself out.

So first go Project properties and click Edit for the JRE System Library.

Next select "Alternate JRE" and select another (or same) JDK installation.
I tried to add an image of the dialogs in Eclipse but had trouble inserting them into this post.

Hope this helps someone

Upvotes: 0

Archit Mishra
Archit Mishra

Reputation: 11

In my case, Reinstalling worked because it was 2019 and had java compiler "Java-13". Have switched to Eclipse-2024 with "Java-21".

Upvotes: 0

Elikill58
Elikill58

Reputation: 4938

I got this issue while using gradle. The ./gradlew eclipse didn't changed anything.

For me, I had to edit the .classpath file.

I changed FROM this:

<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
    <attributes>
        <attribute name="module" value="true"/>
    </attributes>
</classpathentry>

TO this:

<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/>

Then, I restarted eclipse.

My full .classpath file:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" output="bin/main" path="src">
        <attributes>
            <attribute name="gradle_scope" value="main"/>
            <attribute name="gradle_used_by_scope" value="main,test"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="src" output="bin/main" path="resources">
        <attributes>
            <attribute name="gradle_scope" value="main"/>
            <attribute name="gradle_used_by_scope" value="main,test"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/>
    <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
    <classpathentry kind="output" path="bin/default"/>
</classpath>

Upvotes: 0

Akshay
Akshay

Reputation: 1

This Helped me

Steps:

  1. How to resolve java build path problem in Eclipse
  2. Right click the project - select build path - click configure build path
  3. click the librarie tab
  4. remove the jre (error jre) we need to jdk
  5. click Add Library
  6. select JRE system library
  7. click installed jre
  8. click add button : or select jdk in this window if not available the jdk click add button
  9. select the jdk directory in the system
  10. select jdk and apply close
  11. building the project
  12. check it the build path problem resolved

You Can check the link below video:- https://www.youtube.com/watch?v=WHjfJnpwcTQ

Upvotes: 0

Kuntal Ghosh
Kuntal Ghosh

Reputation: 3696

Below are the steps of how I resolved the issue in my system.

  • Restarted eclipse
  • Right click on pom.xml and hit maven clean
  • Again right click on pom.xml and hit maven install

I get build success after maven install is completed.

Upvotes: 2

Faizan Haidar Khan
Faizan Haidar Khan

Reputation: 1215

In Eclipse, Right click Project -> Maven -> Update Project. It fixed errors in my project.

Upvotes: 7

art
art

Reputation: 69

I have similar issue when importing Spring Boot, jdk 11 (using inside docker) project to Eclipse 2019 (2021), in Ubuntu, instead when importing to Inteelij IDEA Community or NetBeans IDEs they do not produce the same set of after-import errors as in Eclipse. The Spring Boot is multimodule maven projects and two child modules give such 2 "problems" in appropriate problems tab:

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

Next 2 errors are produced in two classes of aforementioned maven modules:

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

Manipulation with adding JDK 11 to submodules buildpath just leads to the thousands of problems. Also it is got when I use Eclipse-File-Maven-Update. Moreover when I try to edit most of existing classes or add new ones I got red underline that tells

Implicit super constructor Object() is undefined for default 
constructor. Must define an explicit constructor

. So almost no opportunity to use Eclipse even at prebuild stage as docker-compose should run build and run. Indeed I noted that such issue is produced just when project also uses modules (module-info files introduced in java9). When I import project on jdk 8 (even not installed on system), or even on jdk11 without module-info files all is fine in Eclipse after import. Another difference is that of when I use problem old no module project the Build Path is composed with jre environment 8 and maven dependency items, but when using "module-info" project the Build path contains -module path, and -classpath. So I even do not know where to add jre 11, indeed adding does not resolve issue, just make more errors. So what is the resolution of the case??? What settings to do in Eclipse?

Upvotes: 0

zb226
zb226

Reputation: 10538

I got this out of the blue in a workspace that was working properly before. This problem seems to indicate that the project configuration somehow got corrupted.

Restarting Eclipse didn't help, but in the same vein as the answers dealing with Maven, regenerating the Eclipse project config with:

./gradle eclipse

or

./gradlew eclipse

if you use the wrapper, solved this problem for me.

Upvotes: 0

Sathiamoorthy
Sathiamoorthy

Reputation: 11660

I had faced the same issue and tried different solutions, I have reinstalled my JDK 11 and restarted the machine, after that the issue gets resolved.

Upvotes: 0

z atef
z atef

Reputation: 7709

Here is what made the error disappear for me:

Close eclipse, open up a terminal window and run:

$ mvn clean eclipse:clean eclipse:eclipse

Upvotes: 20

Abinash
Abinash

Reputation: 1

I had faced this problem. I added the C:\Users\Office 2\android-sdks\platforms\android-19\android.jar to the Java Build Path's Library. And the project started to run again. The problem occurred due to my carelessness. Yesterday night I was updating the Android SDK, and at the same time I tried to run the project, while the SDK Manager was uncompressing the system image. The Project couldn't start and the error occurred.

I tried all the methods given by others. But nothing worked. It solved when I added the android.jar to the library.

I guessed it that android library is missing. not the Java, when I saw the errors only at the android methods and imports. But when I read the posts, I got confused and wasted some time trying wrong way.

Upvotes: 0

Thomas P.
Thomas P.

Reputation: 1

At my system the Java Runtime JAR file jrt-fs.jar was not found because it was in the wrong directory. This file should be located in the "lib" subfolder. If you installed Java at "C:\Temp\java" the file should be here at C:\Temp\java\lib\jrt-fs.jar .

These are the steps to make jrt-fs.jar available to Eclipse:

  1. Window / Preferences -> the "Preferences" Window opens
  2. Select in the left menu: Java / Installed JREs
  3. Press the [Add...] Button -> A window opens
  4. Select "Standard VM" - The window "JRE Definition" opens.
  5. Enter your path information:
  6. JRE home = "C:\Temp\java"
  7. JRE name = "MyJRE"
  8. Select [Add External JARs...] to link the jrt-fs.jar
  9. JRE system libaries: "C:\Temp\java\lib\jrt-fs.jar"

It worked for me with OpenJDK12 and Eclipse 2019-09 (4.13.0). Eclipse reported me this error:

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

Upvotes: 0

Ash_s94
Ash_s94

Reputation: 817

Are you using Maven? If so,

  1. Right-click on the project, Build Path and go to Configure Build Path
  2. Click the libraries tab. If Maven dependencies are not in the list, you need to add it.
  3. Close the dialog.

To add it: Right-click on the project, Maven → Disable Maven Nature Right-click on the project, Configure → Convert to Maven Project.

And then clean

Edit 1:

If that doesn't resolve the issue try right-clicking on your project and select properties. Select Java Build Path → Library tab. Look for a JVM. If it's not there, click to add Library and add the default JVM. If VM is there, click edit and select the default JVM. Hopefully, that works.

Edit 2:

You can also try going into the folder where you have all your projects and delete the .metadata for eclipse (be aware that you'll have to re-import all the projects afterwards! Also all the environment settings you've set would also have to be redone). After it was deleted just import the project again, and hopefully, it works.

Upvotes: 17

Thracian
Thracian

Reputation: 67481

I'm also using Eclipse Oxygen, migrated from Mars. I faced the same error. I deleted .metadata, .recommenders folders and added projects from archive and issue is solved. I also use Android Studio but i like Eclipse much more.

Upvotes: 1

Related Questions