5

Eclipse uses console view as read-only.

How can I type command in console view? Is it possible? E.g: ls, mvn install...

Edited:

Thanks Ben and Kelly.

I understand I can interact with Eclipse's console when my application is running. However, I meant I want an embedded console as like as the one in Kate, Dolphin (press F4 in Dolphin)... So I can use bash script in Eclipse's console. Is that possible? Or is there a plugin for that? I have googled but perhaps my keywords were not right...

Edited

Edward has found duplicate question here: Is there an Eclipse plugin to run system shell in the Console?

And it was answered :-)

I don't know how to mark this one as solved. So I place message here, I got the answer.

Edited

But it is not useful. It doesn't have auto complete feature, when I need to type a long file name, or want a hint for a forgotten name,... it is worst :-(

Community
  • 1
  • 1
  • It isn't read-only. If you were to run a Java application that read from `System.in`, then you would be able to interact with it in the console. Are you trying to spawn a shell in the console? – Edward Thomson Jan 11 '12 at 19:04
  • Thanks Edward. My bad question. I have edited it. Could you please review it and help me? –  Jan 11 '12 at 20:26
  • 2
    possible duplicate of [Is there an Eclipse plugin to run system shell in the Console?](http://stackoverflow.com/questions/1562600/is-there-an-eclipse-plugin-to-run-system-shell-in-the-console) – Edward Thomson Jan 11 '12 at 20:30
  • It's wonderful. I have been using external terminal with `Alt-Tab` for long time. Thank you very much, you save my fingers :-D –  Jan 11 '12 at 20:33
  • I feel you. I hope you will get your answer one day :-) – Federico Giorgi May 15 '17 at 15:30

3 Answers3

2

When the console is waiting for input it shows a green prompt that allows you type.

You can test it out by making a simple console application that reads from standard input.

Ben S
  • 68,394
  • 30
  • 171
  • 212
  • Thanks, I understand it. That is my application is running. I meant I want an embedded console as like as the one in KWrite, Kate... I'll edit my question for more clear. –  Jan 11 '12 at 20:15
  • Thanks! I wasn't using the `Scanner` class to read it from `System.in`. I was actually using the `Console` got from the `System.getConsole()` method which works when using a real console. – asgs Apr 13 '14 at 00:56
2

You are trying to think of the Eclipse console as if it were connected to a command-line process. It is actually connected to the JVM used to execute your Java code. Thus, it only shows output that your program sends to System.out and conversely only is available for input if the Java code you are running is requesting input from System.in.

A decent exercise would be to write a small Java program that redirects the input and output to a child process of your favorite shell, for example: http://www.devdaily.com/java/edu/pj/pj010016

Kelly S. French
  • 12,198
  • 10
  • 63
  • 93
  • Thank you, I understand it. But as I replied to @Ben, I'll edit my question for more clear. –  Jan 11 '12 at 20:16
0

The Eclipse Console view is used for communicating with an executed program (typically Java, or similar). If you want to use it as a console, as mentioned in the comment under @Ben S's answer, the Target Management Eclipse project provides a view that can be used for that reason. I don't have it installed right now, so I cannot tell you the required plug-in/view name, but I have used it to connect to the local computer and works.

Zoltán Ujhelyi
  • 13,788
  • 2
  • 32
  • 37
  • Thanks Zoltán, but I prefer the built-in solution of Edward. If I need TM in the future, I will go get it. Thanks again :-) –  Jan 11 '12 at 20:44
  • 1
    Well, that's the same plug-in I was talking about. It might be built-in in some Eclipse distributions, but I am sure it's not built-in in all ones. E.g. it's not included in mine. :D But I'm glad if that suits you. – Zoltán Ujhelyi Jan 11 '12 at 23:54