views:

30

answers:

2

I am new to eclipse and java. The way I understand the directory structure is that you have source packages in src/ folder and they are built into the /build folder.

It was all working fine until recently. But today I tried debugging after creating a new class and it was throwing ClassNotFoundException when I do F11. On investigation, I found that it was using older versions of even the existing classes and not the new builds, and there was no .class file corresponding to my new class. I checked the build/ directory and it seems the builds are also old as it is showing yesterdays last modified time despite the fact that I have made changes today and tried to debug it. This problem is not limited to debugging as I exported the class into a jar file and it is still using yesterday's jar file. What could be the issue here? Is it not 'building' the classes? Have I messed up the default 'build' folder somewhere?

+2  A: 

First you should check, that the "build automatically" feature is activated (menu "Project/Build automatically").

Next you should do a refresh of your whole project to tell eclipse to check for file changes that occured outside of the eclipse IDE.

If all that doesn't help, do a "Project/Clean.../clean all projects" inside eclipse.

tangens
Cleaning did the trick! thanks :) But even now I have to clean everytime to reflect the changes. Any idea why isn't it happening automatically as it used to?
Raze2dust
I use eclipse at work and I use putty+vim to edit files from home. So could that be the reason it got corrupted?
Raze2dust
Yes, if you missed to do a refresh of your workspace files after that (select the project and press F5).
tangens
A: 

I'd stop assuming and find out where Eclipse is putting your newer .class files. They can't be disappearing. Once you know that, compare it to the project set up you have and make sure that you know exactly where the .class files are going.

duffymo
It is taking classes from the build folder. But the build folder itself wasn't getting updated..
Raze2dust