Eclipse - 运行不在本机 Eclipse 控制台中的程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/908488/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:44:27  来源:igfitidea点击:

Eclipse - Running programs not in the native eclipse console

eclipse

提问by

I'm currently writing some ncurses code and the native Eclipse (3.2.2) console can't display its graphics. I'd instead like to run the program through xterm. What I want is to be able to start xterm and run from there. I'd prefer to not get involved with any plugins or that jazz. Just something simple.

我目前正在编写一些 ncurses 代码,而本机 Eclipse (3.2.2) 控制台无法显示其图形。我想通过 xterm 运行程序。我想要的是能够启动 xterm 并从那里运行。我宁愿不参与任何插件或爵士乐。只是一些简单的事情。

EDIT

编辑

So I have the answer and it was pretty simple... Run -> External Tools -> External Tools -> New Launch Config... Then select location of your terminal emulator. /usr/bin/gnome-terminal in my case. after that set the appropriate arguments. "-e ~/ncurses/start" in my case. Then make sure you aren't allocating a console by unchecking that option in the "Common" tab.

所以我有了答案,这很简单...运行 -> 外部工具 -> 外部工具 -> 新启动配置...然后选择终端模拟器的位置。/usr/bin/gnome-terminal 在我的情况下。之后设置适当的参数。就我而言,“-e ~/ncurses/start”。然后通过在“通用”选项卡中取消选中该选项来确保您没有分配控制台。

回答by VonC

Annonadd to his question:

安农补充他的问题:

its a pain to keep switching back and forth from eclipse and the terminal. I'm looking for a way to just hit something like"F5" and have it run my ncurses program in a new xterm terminal process

不断从 eclipse 和终端来回切换是一种痛苦。我正在寻找一种方法来点击“F5”之类的东西并让它在新的 xterm 终端进程中运行我的 ncurses 程序

The simplest way to do that is to report the command line into an external tool configuration, and point eclipse to use a shell (like described in this program)

最简单的方法是将命令行报告到外部工具配置中,并指向 eclipse 使用 shell(如本程序中所述

http://www.avajava.com/tutorials/eclipse/how-do-i-open-a-windows-command-prompt-in-my-console/how-do-i-open-a-windows-command-prompt-in-my-console-03.gif

http://www.avajava.com/tutorials/eclipse/how-do-i-open-a-windows-command-prompt-in-my-console/how-do-i-open-a-windows-command- prompt-in-my-console-03.gif

In the argument, you will add the command line eclipse execute (command line which can be retrieved as mentioned in the second part of this answer below).
Of course, replace 'cmd.exe' by the shell of your choice, and try not settingthe 'Allocate Console' checkbox in the Common tab of that external launcher.

在参数中,您将添加命令行 eclipse execute(命令行,可以按照本答案的第二部分中所述进行检索)。
当然,用您选择的 shell 替换 'cmd.exe',并且尽量不要Allocate Console在该外部启动器的 Common 选项卡中设置' ' 复选框。

http://www.avajava.com/tutorials/eclipse/how-do-i-open-a-windows-command-prompt-in-my-console/how-do-i-open-a-windows-command-prompt-in-my-console-04.gif

http://www.avajava.com/tutorials/eclipse/how-do-i-open-a-windows-command-prompt-in-my-console/how-do-i-open-a-windows-command- prompt-in-my-console-04.gif



To launch through a xterm, without eclipse involved (not what you are asking for, just keep here for archive)

要通过 xterm 启动,不涉及 eclipse(不是您所要求的,只需保留此处存档)

You can launch your program through Eclipse (Run Configurations), and observe through a 'ps' command the exact Java command line used.
Or launch it in debug mode, and right click the task in Debug view and open Properties. It will show the command line, as documented here.

您可以通过 Eclipse(运行配置)启动您的程序,并通过“ps”命令观察所使用的确切 Java 命令行。
或者在调试模式下启动它,然后右键单击调试视图中的任务并打开属性。它将显示命令行,如此处所述

Then launch that command line directly in your console (Eclipse being not involved at all at this point).

然后直接在您的控制台中启动该命令行(此时根本不涉及 Eclipse)。

http://www.aicas.com/jamaica/3.4/doc/html/debugger1.gif

http://www.aicas.com/jamaica/3.4/doc/html/debugger1.gif