1

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?

SalkinD
  • 753
  • 9
  • 23
  • Possible duplicate of [How can I redirect console output to file?](http://stackoverflow.com/questions/20155744/how-can-i-redirect-console-output-to-file) – Gabriel's Messanger Oct 31 '15 at 16:33
  • its not. The post you linked does not work, as this was not the problem. See the anwer of Jon Skeet. – SalkinD Oct 31 '15 at 17:09

1 Answers1

8

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".

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194