Java – what exactly is system out?

I've noticed that system. Net has never been initialized through a jar file launched from the command line (that is, the runnable jar file launched by the user by double clicking) out. Any call to println () does not open the console

After doing some research, I found several answers on the website:

> System. out. println in jar

> What happens to “System.out.println()” in executable jar?

As far as I know, system Out does not represent the console It does represent data that can be processed by anything that needs to display it Am I right?

>What exactly is system out? > How do I open the console by double clicking the runnable jar file launched from the user?

Solution

Processes in modern operating systems (and several older operating systems) obtain three standard "streams" associated with them:

>Standard input: stream based input (stdin) > standard output: stream based output (standard output) > standard error: stream based error output (stderr)

They are collectively (and creatively) called standard streams

By default, system in,System. Out and system Err is Java's standard mechanism for writing these streams

The program called from the command line runs in the environment where the keystroke in the command line goes to stdin, and the output of stdout and stderr is displayed as text in the console They can be redirected to files, etc

Programs launched through the GUI usually do not hook these streams to anything you can see

I said "default" above, because you can use calls on the system to change the location of these streams (they have innovative names, such as setin, setout, and seterr.)

There is a false correlation: the fact that the jar can run is not why you don't see the stream If you run a runnable jar on the command line, you will see its standard output

If you run it without being associated with a console, whether you can see the output will depend on how you run it and how you might write it Many GUI frameworks redirect standard output and redirect errors to log files Or the application may provide debugging options to do so There is no standard answer (no pun)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>