Java Eclipse 在单独的窗口中打开控制台应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/888599/
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 open console apps in separate window
提问by Omar Kooheji
Is there a way to configure eclipse to open console apps in a new window rather than it's own console when you run/debug them?
当您运行/调试它们时,有没有办法将 Eclipse 配置为在新窗口中打开控制台应用程序而不是它自己的控制台?
I'm debugging a client/server application and I'd like to see the output of both apps at once and not have to switch between the tabs...
我正在调试客户端/服务器应用程序,我想同时查看两个应用程序的输出,而不必在选项卡之间切换...
采纳答案by Fortega
In eclipse, you can have two console views... On the console view, you have a button called 'open console' (the most right button in the console view). If you click this and select option 3 (new console view), you will see two consoles.
在 Eclipse 中,您可以有两个控制台视图...在控制台视图中,您有一个名为“打开控制台”的按钮(控制台视图中最右侧的按钮)。如果单击此选项并选择选项 3(新控制台视图),您将看到两个控制台。
If you right click on the console tab and click on 'detached' the console will be detached from the eclipse frame. (for Eclipse Juno, see the HRJ's comment below)
如果您右键单击控制台选项卡并单击“已分离”,则控制台将从日食框架中分离。(对于 Eclipse Juno,请参阅下面的 HRJ 评论)
You can select which output you want to see on each console by clicking the 'display selected console' button (second button from the right on the console view)
您可以通过单击“显示选定的控制台”按钮(控制台视图右侧的第二个按钮)来选择要在每个控制台上看到的输出
回答by Ross Judson
I have a different solution to this that works for my situation, and can probably be adapted by others.
我有一个不同的解决方案,适用于我的情况,并且可能会被其他人调整。
I actually want a real second console window -- gnome-terminal in my case. I want this because I want ANSI color support and I want JLine to operate correctly. I can separately start my program and connect remotely for debugging, but that's annoying.
我实际上想要一个真正的第二个控制台窗口——在我的例子中是 gnome-terminal。我想要这个是因为我想要 ANSI 颜色支持并且我想要 JLine 正确运行。我可以单独启动我的程序并远程连接进行调试,但这很烦人。
Locate where Java runs from, for the JRE eclipse will run as part of your debug config. Create a script there named gjava, give it the following content, and set it executable:
找到运行 Java 的位置,因为 JRE eclipse 将作为调试配置的一部分运行。在那里创建一个名为 gjava 的脚本,为其提供以下内容,并将其设置为可执行:
#!/bin/sh
gnome-terminal -x java $*
Then, in your launch configuration, on the common page, uncheck "Allocate console". On the JRE page, under Java executable, choose "Alternate" and enter gjava.
然后,在您的启动配置中,在公共页面上,取消选中“分配控制台”。在 JRE 页面上的 Java 可执行文件下,选择“备用”并输入 gjava。
When Eclipse launches in debug mode, it will launch a gnome terminal and pass the remaining args to the Java processor, which will be running inside its window.
当 Eclipse 在调试模式下启动时,它将启动一个 gnome 终端并将剩余的参数传递给 Java 处理器,Java 处理器将在其窗口内运行。
At that point you have a real console that supports JLine, ANSI colors, and full debug support.
到那时,您就有了一个真正的控制台,它支持 JLine、ANSI 颜色和完整的调试支持。
回答by kirenpillay
When you create the second console, click on "Pin Console" and this will keep the console attached to the last application it was used for.
当您创建第二个控制台时,单击“Pin Console”,这将使控制台连接到它使用的最后一个应用程序。