views:

57

answers:

2

If the java program is compiled as

javac t1.java > a //error contents redirecedt to a,file a.But a doesnt have the error contents

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 a error i.e, println is written as print n ,how to capture this error in file a

The command is executed from linux command prompt

Thanks....

+2  A: 

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

Alex
+6  A: 

Try redirecting the stderr:

javac t1.java 2> error_file 
codaddict