Compilation Batch File Won't Pipe To File

Discussion in 'Java' started by Luc The Perverse, Oct 22, 2005.

  1. 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?

    --
    "It's better to have rocked and lost than never to have rocked at
    all." -John Flansburgh
     
    Luc The Perverse, Oct 22, 2005
    #1
    1. Advertising

  2. Luc The Perverse wrote:

    > 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.
     
    Andrew Thompson, Oct 22, 2005
    #2
    1. Advertising

  3. "Andrew Thompson" <> wrote in message
    news:f7q6f.24994$...
    > Luc The Perverse wrote:
    >
    >> 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.
     
    Luc The Perverse, Oct 22, 2005
    #3
  4. Luc The Perverse

    Ben_ Guest

    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]
     
    Ben_, Oct 22, 2005
    #4
  5. "Ben_" <> wrote in message
    news:435a3e08$0$441$...
    > 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.


    --
    "It's better to have rocked and lost than never to have rocked at
    all." -John Flansburgh
     
    Luc The Perverse, Oct 22, 2005
    #5
  6. Luc The Perverse

    Ben_ Guest

    > 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
     
    Ben_, Oct 22, 2005
    #6
  7. Luc The Perverse

    Alan Krueger Guest

    Ben_ wrote:
    > 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.
     
    Alan Krueger, Oct 22, 2005
    #7
  8. Luc The Perverse

    Roedy Green Guest

    On Sat, 22 Oct 2005 06:13:39 -0600, "Luc The Perverse"
    <> wrote or quoted :

    >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
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
     
    Roedy Green, Oct 23, 2005
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wei

    batch compilation

    Wei, Oct 29, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    497
  2. Wei

    batch compilation

    Wei, Oct 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    483
  3. Rick

    batch compilation of web sites

    Rick, Aug 19, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    377
  4. lee, wonsun
    Replies:
    1
    Views:
    505
    Jack Klein
    Nov 2, 2004
  5. Replies:
    1
    Views:
    248
    Ben Morrow
    Jun 2, 2004
Loading...

Share This Page