Eclipse IDE debugging - code not reflects new changes
Asked Answered
C

3

7

I'm using Eclipse IDE (4.2). When I make a change in Eclipse and try to debug it, the previous version is compiled, but not the new one. To get around this, I do maven clean/build and then refresh the project. But this is very tedious and I need to do it every time I make any changes. Is there another way around this or a plugin that I can use to pick up these changes automatically?

Chockfull answered 30/4, 2014 at 13:18 Comment(8)
Is Project -> Build Automatically ticked? And did you save the relevant file before debugging?Erewhile
Hi, the project is saved. Im new to Eclipse, is there a tickbox to trigger the build automatically when i save it? Or do i need to go Project >> Build AutomaticallyChockfull
When you click Project in the title bar you should see a tick left of Build Automatically, if not click it one time.Erewhile
that still does not work, seems like i still have to clean/install with maven ..Chockfull
That's odd. What Kind of Project is it? Are there any error (in Problems section)? Can you provide a screenshot of your eclipse?Erewhile
Just a basic java application. It seems that eclipse packages the module as a jar and then during debug/compilation runs the code from jar. Is there a way to avoid this? or an automated process? similar to IntelljChockfull
No, it doesn't. It builds all classes to target/ directory and runs them from there. Is your project a dependency used by a different project?Erewhile
@Chockfull how it worked for you?Soft
R
7

Click Project > Build Automatically once and make sure that tick mark is appeared in front of Build Automatically option.

Also you have to enable hot code replace options. Click Windows > Preferences. Go to Java > Debug select all options in Hot Code Replace group

Reactionary answered 1/5, 2014 at 4:31 Comment(1)
Its still Not working, I have tried the same operation in Eclipse Neon and Mars2 . Its picking the old complied jars from the target. Not not will automatically at all. Its annoying to clean and build jars again and again even making a small changes. Will look for more suggestion pls.Sitzmark
M
2

I had the same problem and these steps fixed it:

  • Run -> Run configurations
  • Select the one giving the problem
  • Go to the Source tab
  • Make sure your project is the first entry there
  • Mine had just the Default set there so I had to do this: Add -> Java Project -> Select your Project and add it
Maker answered 24/5, 2016 at 17:39 Comment(0)
M
0

I had the same problem, the reason was a wrong configuration of the javabuilder in the .project managed by Eclipse. I opened it and rewrote the buildspec section so that either Maven or jdt.core can compile. Once done, relaunch Eclipse and if the Project > Build Automatically option is enabled, any change should now be reflected:

<?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
  <name>ProjectName</name>
  <comment>My beautiful project</comment>
  <projects>
  </projects>
  <buildSpec>
    <buildCommand>
        <name>org.eclipse.jdt.core.javabuilder</name>
        <arguments>
        </arguments>
    </buildCommand>
    <buildCommand>
        <name>org.eclipse.m2e.core.maven2Builder</name>
        <arguments>
        </arguments>
    </buildCommand>
  </buildSpec>
  <natures>
    <nature>org.eclipse.m2e.core.maven2Nature</nature>
    <nature>org.eclipse.jdt.core.javanature</nature>
  </natures>
 </projectDescription>
Milkfish answered 15/8, 2021 at 12:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.