Skip to main content
Added stderr collection (likely what people would want if kicking off another program). Also clarified symbols and terms.
Source Link

Instead of redirectingusing ">" to redirect like this:

java Foo > log

do it like thisuse ">>" to append normal "stdout" output to a new or existing file:

java Foo >> log

However, if you also want to capture "stderr" errors (That's assuming that's how you're redirectingsuch as why the output. If it's notJava program couldn't be started), please give more details.you should also use the "2>&1" tag which redirects "stderr" (the "2") to "stdout" (the "1"). For example:

java Foo >> log 2>&1 

Instead of redirecting like this:

java Foo > log

do it like this:

java Foo >> log

(That's assuming that's how you're redirecting the output. If it's not, please give more details.)

Instead of using ">" to redirect like this:

java Foo > log

use ">>" to append normal "stdout" output to a new or existing file:

java Foo >> log

However, if you also want to capture "stderr" errors (such as why the Java program couldn't be started), you should also use the "2>&1" tag which redirects "stderr" (the "2") to "stdout" (the "1"). For example:

java Foo >> log 2>&1 
Source Link
Jon Skeet
  • 1.5m
  • 892
  • 9.3k
  • 9.3k

Instead of redirecting like this:

java Foo > log

do it like this:

java Foo >> log

(That's assuming that's how you're redirecting the output. If it's not, please give more details.)