You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Peter DePasquale <pe...@gmail.com> on 2006/10/15 14:59:02 UTC

Output Beffuering Question - text-based application execution via ant

I'm sure this is a common issue, but I can't seem to find an
answer/explanation for it.

I'm teaching my students ANT in their programming course.  We use only
text-based System.out/Scanner(System.in) I/O in this course.

I am finding that in student programs which require user interaction
(application prompting followed by user input) the prompting seems to be
buffering until the ant execution task (<java>) is completed.

Is there a clear, easy way to have user interaction co-exist with ANT such
that my students can use ant for execution purposes?  I recall a few years
ago we used to be able to do this, but it seems that the situation is now
changed.

There is no problem grabbing the input when the user provides it.  However,
the problem only seems to be that the output is buffered.  Thus, the
students don't see the prompts from their program.  If the user knows what
to enter and when, all will execute perfectly.

Currently they use a run target in a form similar to:
  <target name="run" depends="compile" description="execute the
application">
    <java classname="Project1"/>
  </target>

Thanks.

Re: Output Beffuering Question - text-based application execution via ant

Posted by Peter DePasquale <pe...@gmail.com>.
Thanks, but it didn't.

Through a series of method calls, I print a few welcome strings to the
console (text-based application), and then open a Scanner on the System.in,
print a prompt and wait for string input.  It appears that the program hangs
when run through ANT, but if you were to CTRL-C and "terminate the batch
job", you get:

C:\Documents and Settings\Peter\Desktop\ch11>ant run
Buildfile: build.xml

init:

compile:

run:

     [java] Welcome to the JF Mail Reader.
     [java] Attempting to connect to: pop.gmail.com using the pop3s
protocol...


     [java] java.util.NoSuchElementException: No line found
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(
ExecuteJava.java:180)
     [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:710)
     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java
:178)
     [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:84)
     [java]     at org.apache.tools.ant.UnknownElement.execute(
UnknownElement.java:275)
     [java]     at org.apache.tools.ant.Task.perform(Task.java:364)
     [java]     at org.apache.tools.ant.Target.execute(Target.java:341)
     [java]     at org.apache.tools.ant.Target.performTasks(Target.java:369)
     [java]     at org.apache.tools.ant.Project.executeSortedTargets(
Project.java:1216)
     [java]     at org.apache.tools.ant.Project.executeTarget(Project.java
:1185)
     [java]     at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(
DefaultExecutor.java:40)
     [java]     at org.apache.tools.ant.Project.executeTargets(Project.java
:1068)
     [java]     at org.apache.tools.ant.Main.runBuild(Main.java:668)
     [java]     at org.apache.tools.ant.Main.startAnt(Main.java:187)
     [java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java
:246)
     [java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java
:67)
<<SNIP>>

Right at that multi-blank line, the program is waiting for the user to enter
the hostname to connect to, but the prompt to do so is never displayed.  Why
would this be?  How can I get around it?  It's driving me up a wall to think
that I can't use ANT to run the program due to some issue related to input
reading.  Could it be the Scanner?

Thanks!


On 10/15/06, Martin Gainty <mg...@hotmail.com> wrote:
>
> Peter
>
> Ant uses java. Java depends on the underlying OS resources such as Socket
> I/O handles, File I/O handles as well as standard handles such as
> stdin,stderr and stdout
> flush the output from the java class to the resource and closing the
> connection allows the underlying resource to capture the output and render
> the output
>
> HTH,
> Martin
>
> This e-mail communication and any attachments may contain confidential and
> privileged information for the use of the
> designated recipients named above. If you are not the intended recipient,
> you are hereby notified that you have received
> this communication in error and that any review, disclosure,
> dissemination, distribution or copying of it or its
> contents
> ----- Original Message -----
> From: "Peter DePasquale" <pe...@gmail.com>
> To: <us...@ant.apache.org>
> Sent: Sunday, October 15, 2006 8:59 AM
> Subject: Output Beffuering Question - text-based application execution via
> ant
>
>
> > I'm sure this is a common issue, but I can't seem to find an
> > answer/explanation for it.
> >
> > I'm teaching my students ANT in their programming course.  We use only
> > text-based System.out/Scanner(System.in) I/O in this course.
> >
> > I am finding that in student programs which require user interaction
> > (application prompting followed by user input) the prompting seems to be
> > buffering until the ant execution task (<java>) is completed.
> >
> > Is there a clear, easy way to have user interaction co-exist with ANT
> such
> > that my students can use ant for execution purposes?  I recall a few
> years
> > ago we used to be able to do this, but it seems that the situation is
> now
> > changed.
> >
> > There is no problem grabbing the input when the user provides
> it.  However,
> > the problem only seems to be that the output is buffered.  Thus, the
> > students don't see the prompts from their program.  If the user knows
> what
> > to enter and when, all will execute perfectly.
> >
> > Currently they use a run target in a form similar to:
> >  <target name="run" depends="compile" description="execute the
> > application">
> >    <java classname="Project1"/>
> >  </target>
> >
> > Thanks.
> >




-- 
Peter J. DePasquale, Ph.D.                      238 Holman Hall
Department of Computer Science        The College of New Jersey
PO Box 7718                                Ewing, NJ 08628-0718
===============================================================
http://www.tcnj.edu/~depasqua                  (p) 609-771-2806
(e) depasqua [at] tcnj [dot] edu                  (f) 609-637-5190

Re: Output Beffuering Question - text-based application execution via ant

Posted by Martin Gainty <mg...@hotmail.com>.
Peter

Ant uses java. Java depends on the underlying OS resources such as Socket I/O handles, File I/O handles as well as standard handles such as stdin,stderr and stdout
flush the output from the java class to the resource and closing the connection allows the underlying resource to capture the output and render the output

HTH,
Martin 

This e-mail communication and any attachments may contain confidential and privileged information for the use of the 
designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received
this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its 
contents
----- Original Message ----- 
From: "Peter DePasquale" <pe...@gmail.com>
To: <us...@ant.apache.org>
Sent: Sunday, October 15, 2006 8:59 AM
Subject: Output Beffuering Question - text-based application execution via ant


> I'm sure this is a common issue, but I can't seem to find an
> answer/explanation for it.
> 
> I'm teaching my students ANT in their programming course.  We use only
> text-based System.out/Scanner(System.in) I/O in this course.
> 
> I am finding that in student programs which require user interaction
> (application prompting followed by user input) the prompting seems to be
> buffering until the ant execution task (<java>) is completed.
> 
> Is there a clear, easy way to have user interaction co-exist with ANT such
> that my students can use ant for execution purposes?  I recall a few years
> ago we used to be able to do this, but it seems that the situation is now
> changed.
> 
> There is no problem grabbing the input when the user provides it.  However,
> the problem only seems to be that the output is buffered.  Thus, the
> students don't see the prompts from their program.  If the user knows what
> to enter and when, all will execute perfectly.
> 
> Currently they use a run target in a form similar to:
>  <target name="run" depends="compile" description="execute the
> application">
>    <java classname="Project1"/>
>  </target>
> 
> Thanks.
>