trying to capture javac output in bash shell

I'm trying to redirect the java compiler output to a file. I thought it's supposed to be:

javac file.java > log.txt

or something. Instead, I see all the output on the terminal and nothing in log.txt!

Also, if I want to log errors too, do I do

javac file.java 2>&1 > log.txt

?

Answers


javac file.java 2> log.txt

The reason is that you have two output file descriptors instead of one. The usual one is stdout, which you can redirect with > and it's supposed to be used for resulting output. The second one, stderr, is meant for human readable output like warnings, errors, current status etc., this one is redirected with 2>.

Your second line, using 2>&1, redirects stderr to stdout and finally stdout into log.txt.


Need Your Help

When to enable/disable Viewstate

asp.net web-user-controls

I generaly disable viewstate for my ASP.net controls unless I explicitly know I am going to require view state for them. I have found that this can significantly reduce the page size of the HTML

HTTP Status 500

java netbeans rest

I want to make Restful - Web Service using netbean 6.5, glassfish V 2 , and i already make table and the relationship between table. But when i want to test restful Webservice, some table it show

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.