I compiled a Java program as
javac t1.java > a
in order to redirect the error messages to file a
. But a
doesn't have the error contents (they still appear in the terminal). The command is executed from Linux command prompt.
The contents of t1.java is as:
class t1 {
public static void main(String[] args) {
System.out.printn("Hello World!"); // Display the string.
}
}
So now there is an error, i.e. println
is written as printn
.
How can I capture this error message in file a
?
Try redirecting the stderr
:
javac t1.java 2> error_file
> foo
implies 1> foo
where 1
is the stdout stream.
In bash, if you want to redirect the stderr stream, use 2> foo
The standard Unix fileno's are 0 - stdin, 1 - stdout, 2 - stderr.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With