Eclipse Debugger not following the source code - java

I have encountered a problem with the Eclipse and I am unsure how to fix it. When I enter the debugger and press the step over button the debugger usually highlights the line of source code that I stepped to. However, for some reason this is not working for me anymore. I enter the debugger and go to the breakpoint but if I hit the step button the source is not highlighted and if I continue to hit the step button I can see that the Debugger is stepping into other files (looking at the Thread) but my view of my code doesn't change. The only way I can find what line my Debugger is on is if I control click on the line from Debug tab and click Lookup Source which then highlights the line the Debug Current Construction pointer is on. If I am debugging I would like to follow this Current Construction pointer line by line. I must have accidentally altered this somehow and I am unsure how to change it back.
Simply stated the problem is this, usually the Eclipse Debugger highlights your source code as you step through it. It is not doing that for me anymore, the debugger is stepping properly but it is not highlighting the line of code that it is on.

This happens when we make Java code change in file, compiler creates a class but running server has a old copy of your class file.
Go with JRebel to get rid of such kind of issues.

This can also happen if you have more than one project in you work space, and you create a debug configuration that points at the wrong project base directory.
To resolve this:
Open your debug configuration list (Run -> Debug Configurations)
Select the proper configuration under your Remote Java Application list
Verify that you have the correct project source listed under the Base directory on the Main tab.
If you have the wrong directory selected (say, one that holds a different project), the debugger will start with no issues, but you will not be able to step through your code.

I had the same issue.
There was a workaround for that by right-clicking on associated callstack line in Debug view and selecting "Lookup Source". After that the current instruction line is (green) highlighted as usual. But I needed to do this after every debug step.
Rebuild all projects didn't help.
The solution:
Restart Eclipse and all works fine.

Related

IntelliJ showing code changes (Git)

When I make code changes in IntelliJ, the IDE will show me which lines I've added/modified by color-coding next to the line number.
However, when I commit my changes (git commit ...), then the helpful color-coding disappears. Is there any way to still show the line changes even after I commit them?
It's not 'color' solution but if you right-click on left (might be a line number) and select annotate then you will see some details about git changes in whole file:
If you click on one of them then more info will popup:

netbeans runs program even if there are errors in code

so, I accidentally chose "don't show me this message again" and "Run anyways". is there a way to undo this setting? Like there can be typos throughout the program, and it'll still try to run. I don't want this, because if there's a section of code that might not be called while i'm testing the program, I might not notice the error.
newest version, 7.4 NetBeans EE for windows
if a function call is actually made to the "uncompilable source code", then it gives such an error
I can search through the program manually line by line, making sure there are no red squiggly lines, but this seems impractical. perhaps I should just re-install netbeans?
According to multiple posts on the Internet, you should remove the BuildArtifactMapperImpl.properties file in the <netbeans home>/<version>/config/Preferences/org/netbeans/modules/java/source/ directory (where it is depends on your installation).
It should have the askBeforeRunWithErrors property set to false. Some just fixed buy deleting the whole file.
Personally, I do not have that file but I have not checked that option, so it might be generated at that point.
how about you delete the settings file stored in the your user DIR as an xml file. it will reset netbeans bac to defaults. or you can edit it and locate parameter askBeforeRunWithErrors to false as it's set to true.
There is a red stop button in the output window. Click that.
There is a bug in NB forum. And another forum reply says that
Don't bother - found it after making a directory diff :
Simply remove the file
.netbeans/7.0/config/Preferences/org/netbeans/modules/java/source/BuildArtifactMapperImpl.properties

Issue with 'Source not found'

I'm trying to debug a tomcat server. Also I have installed JadClipse in Eclipse. And I need to stop in classes which have no source file.
So. When I do 'ctrl+open implementation' on method - everything works fine(I see decompiled sources of this file). I even can put a breakpoint inside this method.
But when workflow reaches this breakpoint, it stops on it and I can't see decompiled sources.
What should I do?
And when I turn off console with launched tomcat - decompiled code comes back at the same moment.
I am a debugging adict an understand what your problem is.
It is easy to open and decompile classes that you navigate but it is difficult to do it while debugging it.
What you can try (it is a little tedious but works) it is doing a manual work. As you can see in below image, the Debug panel has different threads for you application. In this case you have a Thread with a Main class and main method, at this line you will find the line number for the process you are debugging. For example:
Main.main(String[]) line: 9
This debugging "line: 9" points you at what line in the class you are watching.
In your case, you can be guided using the line number and can use Ctrl+Open to navigate the sources. You won't see the debugging highlight since you are doing a manual work but it is really helpful to debug decompiled classes.
Hope to help.

Eclipse not pasting copied text (Java/Mac)

I am having this weird problem where when I select text (Cmd-C) and then try to copy it to another location (Cmd-V) it behaves as though it wants to copy the file as if I had the file name selected instead of the text. Trying to paste in a text window pastes the file itself, so it's clear the copy is what is at fault. Trying the menu option to copy (Edit->copy) does the same thing, so it's not a key interpretation issue.
This started happening to me after I had closed eclipse and then re-opened it later. No settings had been changed. A related issue that cropped up that might help identify is that eclipse stopped showing the file/line that the stack trace was on in debug mode (break points work, just doesn't pick up the file/line #). If you right-click on the stack trace item and tell it to go to the source code - it does, and appears to look correct, it just doesn't do it automatically when you hit the breakpoint. Both issues started happening after the restart.
Both are equally disturbing - but this post is primarily about the pasting issue.
The debug trace issue happens to me too. I close Eclipse, then delete the ".metadata\.plugins\org.eclipse.jdt.core" folder in the associated Workspace, then restart. This clears the cache.

How do you step through a program in Eclipse?

I want to follow a Java program so that I can understand how everything works together. I could do it with Visual Studio so I am hoping that Eclipse may also have a feature to step through that I have not been able to find.
Put a breakpoint at a given line (double click before the line, or right-click > toggle breakpoint)
Run the program in debug mode. That is - Debug As > Java program
Whenever the breakpoint is reached, the Debug perspective opens, and you can step through.
Refer step1, step2, step3,step4 images respectively.
Simply put, you can run your code in Debug Mode by pressing only F11 or clicking that little bug on the top of the screen. Use F5 to trace into, F6 to step over, CTRL-SHIFT-B to set/remove breakpoints.
First you must set a break point in your code. The easiest way to do this is to open up the source file where you want to stop your program, find the line of code where you want to set your break point, and right-click the left-hand margin and select 'Toggle Breakpoint.' Once you've done this, launch your program within Eclipse using the Debug mode. To do this, go to Run>Debug Configurations and set up the configuration to run your program. Alternatively, you can open up the source file that is the entry point to your program (it should include your 'public static void main(String args[])' method), and right-click within the editor and go to Debug As>Java Application. Once the program launches and the code in which your break point is reached, Eclipse will open up the debug perspective. This will show where you are within your program and any variables that you have set. You can step through your program using the buttons in the 'Debug View'. You can also use the menu items within the Run menu to step through the program.
All the answers here are not really "cut and dry". To make this debug feature available in the eclipse workspace, first, you need to set the breakpoint properties of Line Breakpoint. Check the box: "Trigger Point" to allow the trigger to initiate at the line that you want it to begin to break during debug mode. Otherwise, you can F11, F5, or F6 all day long, and nothing will allow you to step into your code.

Categories

Resources