13

Some threads asked how to use the "Interactive Console" in Eclipse since you cannot type anything in this console.

Some suggested you can "Display view" to execute code.

So what is the purpose of the "Interactive Console" then?

inetphantom
  • 2,498
  • 4
  • 38
  • 61
Howard
  • 19,215
  • 35
  • 112
  • 184
  • with the interactive console you can evaluate java code and feed it into the program as it runs. So you can slip in additional code while the program is running. My guess is that you can only use it at a breakpoint if it is disabled at runtime (never used it myself). To make a breakpoint, find a source file, and double click just to the right of a line number, causing a blue dot to appear. Then run the program with debugging on. – Bartvbl Aug 02 '12 at 16:22

3 Answers3

27

Eclipse doesn't have an "Interactive Console" in it's default installation. It just has a "Display" view that you can use to execute Java code in debug mode in the scope of the current breakpoint (to evaluate expressions or to change data)

If you have an "Interactive Console", it's most likely a view from a plugin. I've read that a Google plugin might provide it. Or maybe a plugin for a scripting language like JRuby or Groovy.

If you say you have an "Interactive Console" and cannot type into it, then I suspect you're not in the right mode for the view to be active (maybe you're not working with the scripting language that provides the view).

mmey
  • 1,545
  • 16
  • 24
  • 1
    Add org.eclipse.dltk.debug.ui to plugins that will contribute the "Interactive Console" view. – Kevin Oct 14 '14 at 18:56
  • Hi, I am facing the third point you mentioned. I am not able to type in interactive console. I am working with PHP only. How do I find what is wrong? – Gibbs Sep 20 '15 at 15:37
  • 2
    The console in question is aided by Eclipse Dynamic languages toolkit (DLTK ) and unfortunately gets enabled by default in java debugging sessions causing a lot of confusion. In case of dynamic languages like perl and python developer can enter code during a debugging session and get it evaluated on the fly. the console is useless incase of a java debugging sesssion. – Gautam Jan 24 '16 at 13:12
6

Im sorry but the accepted answer is not correct.

The console in Eclipse is interactive, when a running application reads from the Console Input Stream.

It is not meant to be a feature of Eclipse to generally aid in debugging, it is meant to allow console based Java applications to read input from the user when debugging (as in I can type into a console prompt).

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
deleted_user
  • 3,817
  • 1
  • 18
  • 27
  • 1
    I didn't say "The eclipse console is not interactive". I said: Eclipse doesn't have an "Interactive Console" (meaning a view called "Interactive Console") in its default configuration... Of course the input stream will be connected to the console, but the "Interactive Console" people talk about in this thread is something else. – mmey Aug 13 '12 at 22:33
2

EARLIER ANSWER (accepted but not correct) :

The interactive console allows you to execute some extra code, while debugging, when stopped at via a `breakpoint`.

This is a really beneficial feature when you are debugging and suddenly want to change the value of variable, execute a sysout or some utility function. 

FOR Correct Answer look at the answer below by @mmey.

Bharat Sinha
  • 13,973
  • 6
  • 39
  • 63
  • 4
    But when I stopped at the break point, I can't enter anything into the interactive console; while I can use `display` view to debug: http://stackoverflow.com/questions/871403/in-eclipse-while-debugging-how-do-i-access-the-interactive-top-level-a-ka-th, but then what is the point of `interactive console`? – Howard Aug 03 '12 at 06:45
  • 1
    My experience is similar to Howard's. In my installation of Eclipse Juno, I stop at a breakpoint in my Java application, but the Interactive Console won't let me enter any text. Is this a bug or what am I missing? Is there any chance this is part of a different debug environment (like Javascript debug or the Ruby toolkit)? – Bob Kuhar Aug 09 '12 at 20:02
  • FYI, you can `execute a sysout or some utility function` by typing the method you'd like to run in the "Expressions" view. If you type there `System.out.println("foo")` then "foo" would be printed on the console every time when Eclipse would evaluate the expression to compute its value. – jutky Sep 15 '14 at 10:49
  • this answer is not accurate. the real answer is right below this one from @mmey .. go through all the comments as well to get a clear picture. – Gautam Jan 24 '16 at 13:12