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 > 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 2>&1 > log.txt



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

Have you tried

javac -Xstdout log.txt

This will send compiler errors to a log file instead of stderr.

Need Your Help

Setup a test environment on my local machine using Visual Studio

c# .net database visual-studio

What is the easiest way to setup a test environment on my local machine using Visual Studio 2008 with a website that that has a mssql database, which is hosted through a webhost?

How to insert into a table when a button is clicked?

php mysql codeigniter

I have a form to get the employee details like employee id, name etc. I have another table that contains services that the employee can perform. When I create a new employee I need to select servic...