System.out何时不显示在Java控制台中? [英] When does System.out not appear in the Java console?

查看:462
本文介绍了System.out何时不显示在Java控制台中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道任何标准输出( System.out )会出现在Java控制台窗口(启用时)。我发现某处,虽然,可能有一些情况下,这不是尝试,例如,从Swing应用程序。是这种情况吗?

I understood that anything to standard out (System.out) would appear in the Java Console window (when it's enabled). I spotted somewhere though that there might be situations where this isn't try, for example, from Swing apps. Is that the case?

基本上,什么情况或设置不会在控制台看到标准输出?在JDK上运行的行为,而不是在JRE上显式地运行? javaw.exe?

Basically, what situations or setups wouldn't I expect to see standard output in the console? Is there a difference in behavior running on the JDK rather than explicitly on the JRE for example? javaw.exe?

ps,我理解如何在Java设置中显示控制台,但我很好奇,因为我已经设法创建一个应用程序,作为一个可执行jar,尽管在Windows 7上对 System.out 有一些调用,但不启动控制台。

ps, I understand how to display the Console in the Java settings but I'm curious as I've managed to create an application, run as an executable jar, that doesn't start the console despite some calls to System.out) on Windows 7.

推荐答案

我可以想到的一种情况是调用 System.setOut(null)(或 System.setOut除了System.out或System.err之外的任何OutputStream)),则控制台(如果存在)将不显示任何内容。

One situation I can think of is to invoke System.setOut(null) (orSystem.setOut(any OutputStream other than System.out or System.err)) then the console, if exists, would show nothing.

这篇关于System.out何时不显示在Java控制台中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆