开发者

How can I capture Java compiler errors into a file?

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 开发者_JS百科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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜