Why does’ Java – version ‘go to stderr?

Is there any particular reason why Java is converted to stderr?

For example, the command is executed from the prompt line of windows:

java -version > java_version.txt

Java file_ version. Txt leave blank

Editing: executing Java The same is true for printouts without any parameters after exe

Editor: just out of pure curiosity, I checked whether it had always been like this, and it turned out to be Java - version in JDK 1.1 8 is also JDK 1.2 Stderr in 2, but Java without any parameters The output of exe does not

Solution

AFAIK has no special reason It's just an implementation of Java commands

My brief survey shows that this is consistent with the behavior of most linux commands... Everything else I try to use uses stdout However, the - Version / - version option is a convention, not required by any standard

What can / should you do?

>Stderr should be easily captured in a shell script or batch file instead of stdout. > There should be no risk in doing so Oracle cannot change the Java toolchain to send the - version output to stdout without potentially breaking the client script This is very unlikely 1

1 – this proves unlikely: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4380614. Please note "solution: no fix"... And final comments

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
分享
二维码
< <上一篇
下一篇>>