It may be a silly question but I can't find anything on the web with the answer. What (if anything) determines where the args of a System.out.println(args) command will be displayed? I've been using an IO class created by my lecturer which created it's own GUI and wrote to specific areas of that by default but now that I am making my own programs I am struggling to get the text/images/whatever to display where I want it to.
Asked
Active
Viewed 83 times
1
-
Related http://stackoverflow.com/questions/3228427/redirect-system-out-println – leonbloy Jul 09 '13 at 04:16
-
System.out defaults to the standars output stream (this is a object of type `java.io.PrintStream`) if you are trying to display images then you clearly are looking at Swing `JFrame` or applets, in either of the cases there are a lot of things which needs to be checked.. if you want to programatically redirect the default output then use the method `System.setOut(<
>)` – Anantha Sharma Jul 09 '13 at 04:19 -
Thanks, that explains it. I'm using JFrame, trying to get text to write to various areas and images to display and update. What things (roughly) need to be checked for that? – Ratu Jul 09 '13 at 04:48
2 Answers
4
From the Javadocs for System.out
:
The "standard" output stream. This stream is already open and ready to accept output data. Typically this stream corresponds to display output or another output destination specified by the host environment or user.
In most computing environments, there are three standard streams associated with a process.
Note, however, that System.out
can be reassigned in Java, by using System.setOut()
.

Oliver Charlesworth
- 267,707
- 33
- 569
- 680
0
Depending on the operating system you're using, each process has associated a standard input, standard output and a standard error. If you execute your program in a console, the it will be your standard input, output and error.
For instance, in Linux you can redirect the standard output with redirection operators like this:
java MyClass > fileAsOutput.txt

morgano
- 17,210
- 10
- 45
- 56