25

I have a strange problem in Eclipse Helios. When I alter my source code, my changes have no effect. Even if I alter the code in a way that looks uncompilable, it still can be run.

It seems that Eclipse keeps its state somewhere in the background while I edit and save my sources and commit them to svn.

I don't know what setting to look up or what else to do. I'd be glad to receive any help.

Lii
  • 11,553
  • 8
  • 64
  • 88
dajood
  • 3,758
  • 9
  • 46
  • 68
  • 2
    Is "Project->Build Automatically" checked? – Carsten Mar 01 '12 at 01:08
  • 1
    I deactivated the automatic build, did a cleanup, reactivated it. When i now try to run my program, i get an error that says that my main class couldn't be found or loaded. – dajood Mar 01 '12 at 01:20
  • Then it seems to be a classpath problem, are you using a build tool like maven or is it just an eclipse java project? Check your src and build folders from project properties. – Carlos Quijano Mar 01 '12 at 01:53
  • I use maven - i'll check the classpath configuration. – dajood Mar 01 '12 at 01:54
  • Im having the same issue only im using ANT...it seems like ANT is NOT picking up the changes I make in Eclipse when I do the build...Eclipse has all my changes, even if i close and reopen, but if I open the file manually from a directory...i see the older versions, this is happening before and after i do an ant clean build. This has never happend to me before....its driving me crazy.. – Tim Boland Aug 25 '14 at 23:01
  • Sometimes removing error creating jar files in the following helps showng up changes. project > properties > Java BuildPath – nilakantha singh deo Dec 13 '16 at 19:45

12 Answers12

15

Note : Please try this only if you have run out of other options in this thread.

So Just in case the other options like clean/rebuild listen in the other answers, do not address the problem do the following,

Close eclipse Go to the project folder on the hard drive. Delete the .metadata file and restart eclipse and revisit the workspace. The class path and libraries will be re validated and the project fresh built.

Som Bhattacharyya
  • 3,972
  • 35
  • 54
  • 6
    This is useful if you want to nuke your entire workspace and spend a few hours fixing it. Only use this as a last resort. It's especially great when you do this not knowing the consequences and Windows won't let you restore the metadata... Lol – Anonymous Apr 13 '19 at 17:38
  • Well been there done that multiple times over the years in many projects never had an issue. As the OP said its a maven project and generating eclipse project files should be automated already. I am interested in knowing in what situations can windows not let you restore the metadata. – Som Bhattacharyya Apr 14 '19 at 06:10
  • 1
    Can't find any .metadata file. I am on mac. Inside the project directory, I can see .project, .settings though, inside one component directory. – Sandeepan Nath Sep 05 '19 at 14:10
  • @SandeepanNath See if this helps. https://stackoverflow.com/questions/31237683/metadata-folder-missing-on-mac-showing-up-fine-on-pc – Som Bhattacharyya Sep 25 '19 at 06:30
12

In the Project menu, verify that Build Automatically is checked.

Lii
  • 11,553
  • 8
  • 64
  • 88
RMorrisey
  • 7,637
  • 9
  • 53
  • 71
8

I was having the same problem while running a Maven project in Spring Tool Suit (which is based on Eclipse). I needed to clean and build the maven project every time to make the STS detect the new changes (what is obviously a slow and inefficient process).

So my solution was:

Pressing Alt+F5 and check Force update of Snapshots/Releases

Ignacio Alorre
  • 7,307
  • 8
  • 57
  • 94
6

As mentioned before verify your Build Automatically option in Project->Build Automatically, then clean the project so your changes will be compiled again.

Carlos Quijano
  • 1,566
  • 15
  • 23
1

Just go to "Project->Build Automatically" and check it that's all

Elouafi
  • 281
  • 4
  • 12
0

This is on Eclipse (Kepler). Simple "Hello World" in Java where changes to text in println where not reflected in console when doing a run or relaunch (Build automatically was checked). When doing a second relaunch ( or saving the .java file 1st) it always showed the changes to the println.

Kristian

Kristian
  • 406
  • 4
  • 12
0

Try doing some minor changes in the JSP file. Sometimes your Tomcat server contains old cache files which it uses even if you CLEAN BUILD your project. Bringing updates in the JSP files helps Tomcat deploy the JSP file with modifications rather than using the old cache files. I faced a similar problem which was resolved the same way. Thanks to Latest changes are not reflected in servlet (tomcat)

Jasperan
  • 2,154
  • 1
  • 16
  • 40
Dhrumil Panchal
  • 406
  • 5
  • 11
0

This is an old post but I had a similar issue recently which was not resolved by deleting the jar or building it. In Eclipse I tried the following:

Window --> Preference --> LIB --> Expand it and delete the jar (which is to be replaced). 

This will delete the reference from the project. After that I just added it back using:

Properties --> Java Build path --> Libraries and adding the jar. 
Jasperan
  • 2,154
  • 1
  • 16
  • 40
0

It's possible that you have copied the previous code from an old class but that class-name is still same, then this file will be using the old class. Make sure you changed the class name also..

I hope this could solve the problem.

0

Your operating system simply does not allow modifying a file while it is in use, so the compilation fails. The compiler can't remove the old executable and place a new one. Because of this, save the code and restart Eclipse, build, and run again

Jasperan
  • 2,154
  • 1
  • 16
  • 40
Adithya S
  • 1
  • 1
0

Try (re)building or saving first.

-1

This most probably occurs when the meta data related to the workspace is corrupted. Simple solution would be to create an entirely new folder as workspace and import the project into this new workspace.

This is after you have tried all the clean build, rebuild etc.. :)