menemenemu
menemenemu

Reputation: 209

Why isn't Eclipse updating the classes?

Since yesterday, Eclipse is not updating the .class files of my project. For example the filename.java is up to date, but the filename.class file has a modified date of yesterday. It used to work just fine. Why is this happening?

Upvotes: 8

Views: 34613

Answers (11)

Stuart Cardall
Stuart Cardall

Reputation: 2447

This can happen if you add then remove maven support to a project.

Eclipse will still be placing the compiled files into target/classes & not into bin (which you were synchronizing with your webapps folder).

To fix this go into Project Properties & change:

  • Java Build Path => Source => Output folder

Upvotes: 0

RayCh
RayCh

Reputation: 641

I had this problem (on Eclipse Neon). I had to check the JRE System Library before it would update the classes in the target folder:

enter image description here

Hope this help.

Upvotes: 0

Sachin Parse
Sachin Parse

Reputation: 1323

I have faced same problem. And the solution is the Project Java version and JRE System Library.

Follow the bellow steps:

  1. Project -> Properties -> Java Compiler [check version of the Java e.g 1.6]
  2. Project -> Properties -> Java Build Path -> JRE System Library [ check version e.g. java-6-oracle]

Upvotes: 1

Walfrat
Walfrat

Reputation: 5353

Another thing to consider, open the marker windows. If you have a Java Build Path problem, Eclipse won't update them until you resolve them.

Upvotes: 0

Delete the build folder of your project, then clean the project (make sure you have the Build Automatically option enabled)

Upvotes: 0

Kristian Kraljic
Kristian Kraljic

Reputation: 834

Make sure Java builder is active in the Project -> Properties -> Builders menu

Thanks to @ege-akpinar, I found out that for some reason the Java builder in my project settings had gone missing. Unfortunately you can't simply add the builder again. To fix this you'll have to edit the .project file in your projects root folder. Make sure the following lines are present in the file:

<buildSpec>
    <buildCommand>
        <name>org.eclipse.jdt.core.javabuilder</name>
        <arguments>
        </arguments>
    </buildCommand>
</buildSpec>
<natures>
    <nature>org.eclipse.jdt.core.javanature</nature>
</natures>

To make the change I closed Eclipse. Afterwards I checked the Builders preference, cleaned and built the project again. The change made it work again.

Upvotes: 4

DavidS
DavidS

Reputation: 26

Perhaps you have old class files around? When I added my project to Git, it seems the target directories were different. I found duplicate class files in two separate folders - one set was old. Yet, the old set seemed to be the "goto" set for Tomcat. I discovered and resolved the problem by searching for *.class on the root project folder and deleting all results. Once I rebuilt the project - it worked perfectly. (It also fixed my Export to War deployment which also seemed to have been picking up the old class files.)

Upvotes: 0

chirag1992m
chirag1992m

Reputation: 661

The steps I followed when I faced this problem were:

  1. Project > Clean the project.
  2. Check the project's properties. Confirm all dependencies (JRE system libraries and Maven dependencies) are in good shape. If not, update the Maven dependencies or check if the build path is configured properly.
  3. Check if Project > Build Automatically is turned on.
  4. Try to run the project; it should properly re-build the project.

Upvotes: 5

Ege Akpinar
Ege Akpinar

Reputation: 3286

I would suggest doing the following

  1. Make sure Java builder is active in the Project -> Properties -> Builders menu
  2. Clean the project and re-build it.
  3. If that doesn't work, remove the .class files manually via File Explorer and give it another try.

Upvotes: 11

Sathish Prakasam
Sathish Prakasam

Reputation: 1

I had a similar problem when the installed JRE and the compiler versions did not match.

It worked when I selected the same version of the JRE as the compiler.

Upvotes: 0

derdc
derdc

Reputation: 1101

Few things I would do or double check:

  1. Project > Clean on the project you're working on.
  2. Project > Build Automatically - turned on so the code rebuilds in your workspace on saved changes.
  3. Window > Preferences and make sure your Installed JRE's and Compilers are matching Java versions

Upvotes: 22

Related Questions