I tried to make a batch file for compiling Java programs. It looked
something like this
echo off
cls
D:\j2sdk1.4.2_09\bin\javac %1.java>Out.txt
type Out.txt
notepad Out.txt
Except, for some reason nothing gets sent to Out.txt
What am I doing wrong?

Signature
"It's better to have rocked and lost than never to have rocked at
all." -John Flansburgh
> I tried to make a batch file for compiling Java programs. It looked
> something like this
>
> echo off
[1]
> cls
> D:\j2sdk1.4.2_09\bin\javac %1.java>Out.txt
[quoted text clipped - 4 lines]
>
> What am I doing wrong?
Start with [1]. Why are you suppressing output when
things are breaking?
But then ..why would you be getting compilation
output, unless there are compilation errors in the
source? 'javac' is pretty quiet about success.
Luc The Perverse - 22 Oct 2005 14:21 GMT
>> I tried to make a batch file for compiling Java programs. It looked
>> something like this
[quoted text clipped - 18 lines]
> output, unless there are compilation errors in the
> source? 'javac' is pretty quiet about success.
At least while I'm starting, it is a struggle to get it to work, so I
recompile, recompile, recompile . . . then finally when it has all syntax
bugs out, then I run it.
javac writes errors on StdErr.
So, you need to redirect StdErr stream to the file.
Add a '2' before the '>' sign and write it [javac %1.java 2> Out.txt]
Luc The Perverse - 22 Oct 2005 14:46 GMT
> javac writes errors on StdErr.
>
> So, you need to redirect StdErr stream to the file.
>
> Add a '2' before the '>' sign and write it [javac %1.java 2> Out.txt]
Hmm - I don't know why that would work, but I will go try it.

Signature
"It's better to have rocked and lost than never to have rocked at
all." -John Flansburgh
Ben_ - 22 Oct 2005 15:15 GMT
> Hmm - I don't know why that would work, but I will go try it
Why disregard people advise ?
Note, you can also use the non-standard command-line switch:
-Xstdout filename
Send compiler messages to the named file. By default, compiler messages go
to System.err.
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html
Alan Krueger - 22 Oct 2005 17:55 GMT
> javac writes errors on StdErr.
>
> So, you need to redirect StdErr stream to the file.
>
> Add a '2' before the '>' sign and write it [javac %1.java 2> Out.txt]
While I often use this and the "2>&1" idiom to join stderr into the
stdout pipe, I've found in some cases these only work at the command
line and not within bat/cmd files.
>D:\j2sdk1.4.2_09\bin\javac %1.java>Out.txt
is Javac sending to system.out or system.err?
See http://mindprod.com/jgloss/console.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.