“Java 控制台”可以吗?在 JNLP 应用程序中以编程方式启用窗口
例如,当运行 JNLP 应用程序时,将打开“Java 控制台”,其中包含程序的输出和一堆调试功能。
是否打开控制台由 Java 控制面板中的设置决定。
有没有办法启用&在程序执行期间以编程方式显示此 Java 控制台?
或者,如果在程序启动时未启用此 Java 控制台,是否有任何方法可以在程序执行期间启用该控制台?
(我想可能不会,但如果有一种方法可以很好地知道)
br,Touko
When running a JNLP application (for example), "Java console" is opened, containing the output of the program and a bunch of debug functionality.
Whether the console is opened or not, is determined in the settings in Java Control Panel.
Is there a way to enable & show this Java console programmatically during the program execution?
Or alternatively, is there any way to to enable this Java console during the program execution if it wasn't enabled at the program startup?
(I'm thinking that probably not but if there's a way that could be nice to know)
br, Touko
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
安德鲁·汤普森的答案是做到这一点的正确方法。我的答案是快速方法,如果您现在没有时间实现日志框架:
如果您编写的程序没有日志记录,并且您只想查看所有这些 System.out.println 消息,您可以将它们全部重定向到一个文本文件。
在你的 main 方法中,试试这个:
System.setOut(new PrintStream(new File("C:/logs/log.txt"));
您可能希望包含完整路径而不是本地文件引用。
Andrew Thompson's answer is the right way to do this. My answer is the fast way, if you don't have time to implement a logging framework now:
If you have written your program without logging and you just want to see all those System.out.println messages, you can redirect them all to a text file.
Inside your main method, try this:
System.setOut(new PrintStream(new File("C:/logs/log.txt"));
You might want to include a complete path instead of a local file reference.