Print result of java version to file > Why is resulting file empty?

java -version correctly prints Java version. java -version >> test.txt creates an empty file. My problem is that WScript.Shell has exactly the same behavior (empty string returned). Why does this happen, and how to get things right?

Jon Skeet
people
quotationmark

java -version displays the version information on standard error rather than standard output... so you need to redirect that:

java -version 2>> test.txt

Here the 2>> means "redirect standard error, appending it to the given file".

people

See more on this question at Stackoverflow