SalkinD
SalkinD

Reputation: 783

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?

Upvotes: 1

Views: 193

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1500145

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

Upvotes: 8

Related Questions