Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

Compilation Batch File Won't Pipe To File

Thread view: 
Luc The Perverse - 22 Oct 2005 13:13 GMT
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

Andrew Thompson - 22 Oct 2005 13:19 GMT
> 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.
Ben_ - 22 Oct 2005 14:26 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]
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.
Roedy Green - 23 Oct 2005 11:17 GMT
>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.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.