如何将 Eclipse 输出 std:out 输出到标准 Windows 控制台

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

How can I make Eclipse output std:out to a standard windows console

windowseclipseconsole

提问by

As eclipse users know, eclipse captures the output of std out and err by default and dumps it into the console that is integrated with the IDE.

正如eclipse用户所知,eclipse默认捕获std out和err的输出,并将其转储到与IDE集成的控制台中。

I would like eclipse to just use a standard windows cmd instance to display std:out and std:err by default, the way most other IDE's do. Does anybody know how to set this up?

我希望 eclipse 只使用标准的 windows cmd 实例来默认显示 std:out 和 std:err,就像大多数其他 IDE 所做的那样。有人知道如何设置吗?

回答by Grey Panther

I don't know if it's possible to redirect to a proper console window, however it canredirect to a file (which is more useful IMHO) - under Run/Debug settings -> Common -> Standard Input and Output (it can even write to console and file at the same time).

我不知道是否可以重定向到正确的控制台窗口,但是它可以重定向到一个文件(恕我直言,这更有用) - 在运行/调试设置 -> 通用 -> 标准输入和输出(它甚至可以写同时控制台和文件)。

回答by JesperE

Well, you could probably extend/replace the existing Console view and add an option to write to stdout/stderr.

好吧,您可能可以扩展/替换现有的控制台视图并添加一个选项来写入 stdout/stderr。

If you're talking about a Java-program and you want it to opena new console window for stdout/stderr, you will probably have to modify the JDT launcher.

如果您正在谈论一个 Java 程序并且您希望它为 stdout/stderr打开一个新的控制台窗口,您可能需要修改 JDT 启动器。

Why would you want to do that? I find it much more convenient to have stdout/stderr in the Eclipse console.

你为什么想这么做?我发现在 Eclipse 控制台中使用 stdout/stderr 更方便。

回答by boutta

Since you haven't said why you prefer stdout in a windows cmd window i'll make some assumptions: - you only want to move the window around outside of Eclipse

由于您还没有说明为什么您更喜欢 Windows cmd 窗口中的 stdout,我将做出一些假设: - 您只想在 Eclipse 之外移动窗口

In the case above you can drag the console window by the tab outside of Eclispe and you open another window you can move around like a cmd prompt.

在上面的情况下,您可以通过 Eclispe 外部的选项卡拖动控制台窗口,然后打开另一个窗口,您可以像 cmd 提示符一样四处移动。

回答by boutta

When you run a java .class from the cmd it automatically outputs to the windows CMD. Either grab the most recent .class file from your bin folder or compile it yourself using javac. then just go to the windows cmd where the class file is and run it using java yourClassesName.class and it will automatically write all output to the windows cmd.

当您从 cmd 运行 java .class 时,它会自动输出到 windows CMD。从您的 bin 文件夹中获取最新的 .class 文件或使用 javac 自己编译它。然后只需转到类文件所在的 windows cmd 并使用 java yourClassesName.class 运行它,它将自动将所有输出写入 windows cmd。