3

I have searched and found that indeed Eclipse does not support this 'direct' feature. But, Did I stil miss something? and Is it present in other IDEs?

Let me elaborate my question more -

if a statement falls under execution flow based on an expression evaluation, then why can't we force execute it? (without the execution of the expression).

For example consider this -

... if(bool returnsABoolean) { 
<execute some statement>; 
} 
... 

Can the execution of 'if' be skipped and the statement be executed as a 'next statement'? (I obviously can control the value of 'returnAsBoolean' in the Variables view; but can I not skip (in a controlloed manner) all the statements until a particular statement in the execution?)

Umesh
  • 81
  • 1
  • 9
  • http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-stepping.htm – Deepanshu J bedi Aug 02 '14 at 07:09
  • 2
    Similar question - http://stackoverflow.com/questions/191306/how-can-i-set-the-current-line-of-execution-in-the-eclipse-java-debugger – Umesh Aug 03 '14 at 09:44
  • Another one - http://stackoverflow.com/questions/1651379/moving-the-instruction-pointer-while-debugging-java-in-eclipse?rq=1 ; this clearly states indeed it is not a feature in Eclipse/Java. – Umesh Aug 03 '14 at 09:52

4 Answers4

3

Highlight the code you want to run and right-click/Execute or press Ctrl+U.

Alternatively to "Execute", use "Display" (Ctrl+Shift+D) or "Inspect" (Ctrl+Shift+I) to see the result.

Boann
  • 48,794
  • 16
  • 117
  • 146
Deepanshu J bedi
  • 1,530
  • 1
  • 11
  • 23
1

Debugging allows you to run a program interactively while watching the source code and the variables during the execution.

So debugging is nothing but executing program but inspecting the elements during execution but you can not jump into something which is not there in execution.

You can use keyboard buttons F5,F6 ,F8 etc. (For Eclipse) and other Shortcuts during debugging for your convinience but you can't jump to something directly which is not in the execution sequence.

Debugging Shortcuts:

F5 Step into
F6 Step over
F8 Resume and will take you to the break point
Ctrl+Shift+B Toggle breakpoint
Ctrl+Shift+D Display Info of current statement
Ctrl+Shift+I Inspect the selected element

You can Skip some code by the use of breakpoint you can directly jump to specific point and avoid debugging of code which you believe works fine.Or you can jump out code snippet if you want to.

akash
  • 22,664
  • 11
  • 59
  • 87
1

Looks like you want the 'Display' view - in the Debug perspective, do : Window -> ShowView -> Display.

You can enter Java statements to execute there (you have to select the bit of text each time that you want to execute)

http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fviews%2Fdisplay%2Fref-display_view.htm

racraman
  • 4,988
  • 1
  • 16
  • 16
1

The question really was to set the Instruction pointer at will. This has been discussed and through url's i pasted on the comments above - this is not an eclipse feature (yet).

Umesh
  • 81
  • 1
  • 9