Command line output to TXT file (Java.exe -version) Return empty

I need to output some information about checking java.exe in a text file. Command line command

C:\Windows\System32\Java.exe > C:\Users|txt.txt outputs everything to the correct file.

When I try to add -version

C:\Windows\System32\Java.exe -version > C:\Users|txt.txt, the output text file remains blank.

Is there a way to get this in a txt file?

+3
source share
2 answers

Use this command line instead:

C:\Windows\System32\Java.exe -version 2> C:\Users\txt.txt

(note the extra 2.)

Java writes version information to standard error (channel 2), not standard output.

+22
source

The java -version command outputs its outputs to a standard error. Thus, you can redirect these outputs using "2>".

+3
source

All Articles