4

I need to output some information regarding the java.exe verison to a text file. The command prompt command

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

When I try to add the -version

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

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

2 Answers 2

25

Use this command line instead:

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

(note the additional 2.)

Java is writing the version information to standard error (channel 2) rather than standard output.

Sign up to request clarification or add additional context in comments.

2 Comments

why is that? I mean why the output goes to standard error rather than standard output???
@opensas: I don't know, but if I had to guess I'd say that stdout is reserved for the Java program itself, so anything from the runtime rather than the program goes to stderr.
3

The command "java -version" prints its outputs into the standard error. So, you can redirect those outputs using "2>".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.