(Eclipse) 如何与控制台视图交互?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8825042/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
(Eclipse) How to interact with console view?
提问by
Eclipse uses console view as read-only.
Eclipse 使用控制台视图作为只读。
How can I type command in console view? Is it possible? E.g: ls
, mvn install
...
如何在控制台视图中键入命令?是否可以?例如: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...
我知道我可以在我的应用程序运行时与 Eclipse 的控制台进行交互。但是,我的意思是我想要一个嵌入式控制台,就像 Kate, Dolphin 中的控制台一样(在 Dolphin 中按 F4)...所以我可以在 Eclipse 的控制台中使用 bash 脚本。那可能吗?或者有没有插件?我用谷歌搜索过,但也许我的关键字不正确......
Edited
已编辑
Edward has found duplicate question here: Is there an Eclipse plugin to run system shell in the Console?
Edward 在这里发现了重复的问题: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 :-(
但它没有用。它没有自动完成功能,当我需要输入一个长文件名,或者想要一个忘记名字的提示时,......这是最糟糕的:-(
回答by Ben S
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.
您可以通过创建一个从标准输入读取的简单控制台应用程序来测试它。
回答by Kelly S. French
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
.
您试图将 Eclipse 控制台视为连接到命令行进程。它实际上连接到用于执行 Java 代码的 JVM。因此,它只显示您的程序发送到的输出,System.out
相反,如果您正在运行的 Java 代码正在请求来自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
一个体面的练习是编写一个小型 Java 程序,将输入和输出重定向到您最喜欢的 shell 的子进程,例如:http: //www.devdaily.com/java/edu/pj/pj010016
回答by Zoltán Ujhelyi
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 ManagementEclipse 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.
Eclipse 控制台视图用于与执行的程序(通常是 Java 或类似程序)进行通信。如果您想将其用作控制台,如@Ben S 回答下的评论中所述, 目标管理Eclipse 项目提供了一个可用于该原因的视图。我现在没有安装它,所以我不能告诉你所需的插件/视图名称,但我已经用它连接到本地计算机并工作。