score:15
The first two answers seem to miss the topic, unless it is me not understanding the question.
My understanding, a feature I searched myself, is that you want to skip a number of lines (when stepping in code) and set the program counter (to take assembly vocabulary) to the given line. It might be interesting to skip some costly object creation, see some error situations, etc. I used to do that in Visual Studio (C or C++ code).
I haven't found that in Eclipse, nor in NetBean. It might be a limitation of JVM, or an enforcement of some policy...
The Run to line command execute, of course, all lines between the current execution position and the designated one.
score:-5
"Run to line" appears to need the program to be running and in a paused state to use. The other option is to set a breakpoint for that line when running in debug-mode.
- Double-click far-left vertical bar in the source pane on the same line to add a breakpoint; or,
- Select the line and go to Run > Toggle Breakpoint.
At least, this is in Eclipse 3.3.2.
score:0
Feature request saying it is not possible
In https://bugs.eclipse.org/bugs/show_bug.cgi?id=287795 (credits to Amitd) Darin Wright says it is a limitation of the underlying Java debugger:
Currently, this is not possible with the Java debugger as the native debug interface does not provide the ability to move/set the program counter arbitrarily.
C / C++
CDT supports it however (tested on Neon, Ubuntu 14.04). Right click on the line you want to go to, and select either:
- "Move to line": jump to line and break there
- "Resume at line": jump to line and continue execution from there
This also serves as further evidence that there is an underlying Java limitation, as Java tends to be more feature rich in Eclipse, and those menu entries are not present in Java next to "Run to line" (which does not skip execution of lines).
This test program prints 0 if you jump the line i = 1
:
#include <stdio.h>
int main(void) {
int i;
i = 0; /* Break here. */
i = 1;
printf("%d\n", i); /* Jump to here. */
}
score:2
I think that is not possible in Java. The only feature that allows you to "step back" is using "drop to frame", which takes you back to the first instruction of the current frame. At least I haven't seen any debugger with this specific functionality, but I haven't been able to find on the net why is it so...
I know the debugger in Visual C allows to change to pointer. I will keep on searching, maybe at least we will know why is like this, but it seems to be some kind of design limitation.
score:11
I too have long sought this feature, and "Run to line" is not the same thing.
This may well be a limitation of the JVM. Java does not implement goto, though it does have jump statements, like break and continue. Those are at the block level however. If this is a JVM limitation, my guess is that it is more likely due to the security architecture. Tight control of the program counter is debilitating for interlopers, like viruses -- and sadly debuggers.
Source: stackoverflow.com
Related Query
- How can I set the current line of execution in the eclipse java debugger?
- How do I set the Java path in Eclipse so I can run it on an external drive?
- How can I tell Eclipse to import files from outside the current Java Web Project?
- How can I collect some hardware profile data during the execution of the Java program with eclipse and JVM monitor?
- How to change the color of current line & text selection in eclipse (for Java)?
- How to know the command line used by Eclipse to run the java program?
- How can I use the java Eclipse Abstract Syntax Tree in a project outside Eclipse? (ie not an eclipse plugin)
- How do I add a shortcut key to Eclipse 3.2 Java plug-in to build the current project?
- Can I set Eclipse to only emit errors, warnings, etc. for the current project?
- How can I look at the current environmental variables that eclipse IDE is using?
- How to highlight current line of execution in debug perspective in Eclipse
- How can I enable the Task List in Eclipse for a Java Project?
- How do I set the Java Doc for google drive api for android in Eclipse
- Eclipse - how can I determine the number of methods in a Java application
- How can I set the java.library.path used by eclipse from a POM?
- How can I get Mylyn for Eclipse to filter the Bookmarks view based on the current task?
- How can I make the Eclipse Python debugger more reliable?
- How can I keep the Eclipse debugger from automatically expanding the Package Explorer into libraries on exceptions?
- How can I set up Eclipse to edit Perl without the runtime checking?
- In an eclipse plugin: How can I programmatically highlight lines of codes in the java editor?
- How to get the current project path from eclipse using java
- How can I find the version of the Eclipse Java compiler (JDT)?
- Eclipse compiler options - How can I set the debug level
- how to check the current workspace of Eclipse and the project on that workspace using java program?
- eclipse cdt - how to set the active build configuration from the command line
- How can I prevent Eclipse from adding the 'final' for certain lines of Java code?
- How to control the pop up java execution in eclipse
- how can i minimize the stack trace in eclipse java tomcat?
- How can I use a GUI debugger on the Prolog code that runs inside a Java app through JPL?
- How can I make Maven set up (and keep up to date) the build path for my Eclipse project?
More Query from same tag
- How to navigate to nth page in pagination using Selenium WebDriver with java
- Maven Failed to execute goal com.jayway.maven.plugins.android.generation2
- I have an Eclipse IDE for java development. How can i use the same IDE for JSP?
- VideoView won't autolay... (Android/Eclipse)
- Can't run exe file from cmd in Java
- My Eclipse can no longer run (or debug) my JUnit tests
- Eclipse: fully remove an old project?
- Scatter Plot will not change color
- Grayscale to Binary?
- Installing ADT into Eclipse-Juno. How to complete the installation after errors?
- How to configure solr4 with eclipse Kepler?
- Android SQLite database lifecycle
- Java ClassNotFoundException under Tomcat in Eclipse
- Eclipse is not showing "Run as Java Application" option. Only shows "Run Configurations"
- Use tomcat without eclipse
- Using XDebug to trace a PHP web service page
- Portable Eclipse and Google Plugins
- Build error using C++ Eclipse
- How to set the runtime of JiST/SWANS within eclipse
- Git why newly checked remote branch has changed files?
- Where's the native executable in my application?
- Adding a user library to the Web Deployment Assembly will overwrite the contents of the WEB-INF directory
- Main class won't read the other one, project inserted using SVN
- How do I configure a resource filter in Eclipse?
- Listview items getView repeating itself again and again
- eclipse doesn't show an active device in the Run Configurations window
- can't see layout outline in eclipse
- Error with the installation of AWS Toolkit for Eclipse
- How to get the contents of a specific revision of a file using subclipse
- Save WizardPage Settings with Java