Compilation Batch File Won't Pipe To File

L

Luc The Perverse

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?
 
A

Andrew Thompson

Luc said:
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
type Out.txt
notepad Out.txt

Except, for some reason nothing gets sent to Out.txt

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

Luc The Perverse

Andrew Thompson said:
Luc said:
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
type Out.txt
notepad Out.txt

Except, for some reason nothing gets sent to Out.txt

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.

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

Ben_

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]
 
L

Luc The Perverse

Ben_ said:
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.
 
A

Alan Krueger

Ben_ said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top