This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 47708

Summary: [40cat] Cannot send console input to running app
Product: projects Reporter: Milan Kubec <mkubec>
Component: AntAssignee: Jesse Glick <jglick>
Status: RESOLVED FIXED    
Severity: blocker CC: athompson, jchalupa, jpospisil, mmirilovic, phrebejk, pkeegan, sgsst, tboudreau, tmulligan
Priority: P2 Keywords: RELNOTE
Version: 4.x   
Hardware: All   
OS: All   
URL: http://issues.apache.org/bugzilla/show_bug.cgi?id=24918
Issue Type: DEFECT Exception Reporter:
Attachments: Patch JAR against Ant 1.6.2

Description Milan Kubec 2004-08-23 14:10:58 UTC
[dev-200408221800]

There is no way how to interact with non-GUI
application throught Output window. Output window
doesn't behave as console when user input is
requested. Must work for running and for debugging
for j2seproject.
Comment 1 Petr Hrebejk 2004-08-23 14:22:36 UTC
Hmm, looks like someone noticed.
Comment 2 Jesse Glick 2004-08-23 17:01:30 UTC
It's a deficiency in Ant; the IDE technically supports it. I filed a
patch for Ant long ago, but they haven't taken it yet.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24918

Workaround (for running, not debugging): run <java> in nonforked mode
(override -init-macrodef-java), if you trust that your app is not
going to crash the IDE.
Comment 3 Jan Chalupa 2004-08-24 10:47:53 UTC
I'm afraid we cannot dismiss this lightly as "someone else's problem".
Inability to run/debug programs that require console input will be
seen as a deficiency in NetBeans by the uses. Most of them won't care
about limitations of Ant running under the hood.

Can anything be done on our side to fix this? Can Jesse's patch be
bundled with the NetBeans version of Ant? Are there any other
workarounds? (Running java in non-forked mode sounds too dangerous for
general use.)

I'd like to keep this bug open and waive it for 4.0, if there's no way
to fix it.
Comment 4 Petr Hrebejk 2004-08-24 16:37:47 UTC
This option is gone with the new project system. Just compile the
whole project. At will take care of compiling only classes which have
to be changed. If you want to rebuild the project use the clean and
build action.
Comment 5 Petr Hrebejk 2004-08-24 16:38:39 UTC
Oops I did it again. The last comment is about another issue.
Comment 6 Jesse Glick 2004-08-24 17:10:48 UTC
There is no way to fix it short of shipping a patched Ant or shipping
a custom variant of the <java> task. I am not aware of any other
workarounds.
Comment 7 Jesse Glick 2004-08-27 20:03:52 UTC
Summary: the Ant integration in NB 4.0 supports sending text input to
tasks via Ant's normal API for input; and the output window also has a
widget for sending input to the running process.

However the <java> task as of Ant 1.6.2 does not accept console input.

I have filed a patch for the Ant project to permit <java> to accept
console input. So far, it has not been accepted (nor even really
commented on). I can continue to post gentle reminders about it, but I
cannot force acceptance of this patch, much less into a particular Ant
release that we would be able to bundle in time for a NB release.

The most straightforward workaround is to run a Java app in unforked
mode, in which case console input works fine. However this has all the
drawbacks and risks of internal execution generally.

We could apply my patch to <java> and ship a patched Ant, though I
would strongly prefer not be shipping a nonstandard version of Ant.
(The currently filed patch adds a new attribute to <java> to enable
console input; off by default. If we shipped a patched Ant we would
have to enable it by default so that user build scripts would not be
using an attribute not recognized by standard Ant.)

We could perhaps produce a new task similar to <java> but with console
input support, but this is I think even less wise, and it would also
violate our general policy of avoiding use of custom tasks when at all
possible.

Request therefore that this be waived for 4.0.
Comment 8 Jesse Glick 2004-08-27 20:04:54 UTC
More descriptive summary.
Comment 9 Jesse Glick 2004-09-01 22:36:01 UTC
Still up in the air whether and how this can be resolved for 4.0;
might not need waiving.
Comment 10 Marian Mirilovic 2004-09-14 08:56:33 UTC
*** Issue 48729 has been marked as a duplicate of this issue. ***
Comment 11 eberkowi 2004-09-20 22:05:08 UTC
In order to use NetBeans 4.0 Beta to teach my classes I put together a
small replacement console that can be seamlessly added to any console
mode app in NetBeans with one line of code, and is fully interactive.
It dosn't fix the IDE but it is a workable solution until it is fixed.

If anyone is interested in using it, it can be found at 

http://cs.roosevelt.edu/eric/console.html
Comment 12 Jesse Glick 2004-09-23 18:40:47 UTC
*** Issue 49384 has been marked as a duplicate of this issue. ***
Comment 13 gersonfaf61 2004-09-25 01:50:45 UTC
Ok, then how do I run a Java app in unforked
mode? Please help me! Thanks in advance. Gerson.
Comment 14 Jesse Glick 2004-09-25 02:24:59 UTC
Unforked mode workaround: go to build-impl.xml, copy the <target
name="-init-macrodef-java">, and paste into build.xml. Then edit
fork="true" to fork="false".

But BEWARE that in this case, some critical bugs (e.g. AWT-related
deadlocks) in your app could cause the IDE to also hang or crash;
normal exceptions should just cause the build to fail cleanly. So make
sure all files are saved, etc. Also in unforked mode there can be some
subtle problems in case your app's classpath includes packages that
overlap packages in NB's startup classpath - unlikely scenario but
possible. Similarly, your app will not be able to set a new
SecurityManager or do a few other special operations that affect the
entire VM. Many straightforward kinds of apps will be unaffected by
any of these caveats, but be careful.
Comment 15 Petr Nejedly 2004-10-14 13:07:55 UTC
*** Issue 50420 has been marked as a duplicate of this issue. ***
Comment 16 Petr Nejedly 2004-10-14 13:23:26 UTC
*** Issue 50420 has been marked as a duplicate of this issue. ***
Comment 17 Milan Kubec 2004-10-14 13:25:58 UTC
*** Issue 50419 has been marked as a duplicate of this issue. ***
Comment 18 Jesse Glick 2004-10-28 21:43:30 UTC
Still no known good workaround in 4.0; will still try to fix in Ant
itself.
Comment 19 Jan Chalupa 2004-11-08 21:39:39 UTC
*** Issue 50773 has been marked as a duplicate of this issue. ***
Comment 20 _ lcincura 2004-11-15 15:01:08 UTC
*** Issue 51301 has been marked as a duplicate of this issue. ***
Comment 21 Jan Chalupa 2004-11-26 22:41:43 UTC
*** Issue 50064 has been marked as a duplicate of this issue. ***
Comment 22 Milan Kubec 2004-12-07 09:42:07 UTC
*** Issue 52140 has been marked as a duplicate of this issue. ***
Comment 23 Milan Kubec 2004-12-09 08:48:49 UTC
*** Issue 52234 has been marked as a duplicate of this issue. ***
Comment 24 Milan Kubec 2004-12-09 08:49:06 UTC
*** Issue 52234 has been marked as a duplicate of this issue. ***
Comment 25 _ tboudreau 2005-01-05 04:53:55 UTC
*Lots* of duplicates of this message, and it just came up again on nbusers.  Any status on 
doing something about it for 4.1?  

A patched Ant might not be a bad idea if this is likely to stay broken for much longer.
Comment 26 Jesse Glick 2005-01-10 23:51:56 UTC
Distributing a patched Ant to solve this issue has been considered as
an option.
Comment 27 _ tboudreau 2005-01-11 19:22:05 UTC
Shouldn't we make a decision on whether or not to do that for 4.1 really soon?  I have a 
feeling if it's not in the plan, this will stay broken...
Comment 28 Steve Olson 2005-01-12 19:54:59 UTC
Ant or not, expectations are that a developer can execute a java 
program within the IDE and interact easily with the System.in, 
System.out, and System.err period.  This issue is raised on nbusers 
at least weekly if not more often, and, as noted above, there are 
about a dozen duplicate entries in Bugzilla for this same issue, 
which is also an indication of its serious nature.

Please consider a patch release to address this issue-- unless the 
4.1 release is imminent.
Comment 29 Jesse Glick 2005-01-28 02:57:45 UTC
Ant #24918 was committed to the trunk for 1.7. TBD whether it will go
into Ant 1.6.3. TBD whether NB 4.1 will be able to bundle Ant 1.6.3.
Bundling a patched 1.6.2 will be considered if necessary.

See also issue #54116 and issue #54117 for problems on the NB side
with sending input.
Comment 30 Jesse Glick 2005-01-28 03:54:55 UTC
Created attachment 20023 [details]
Patch JAR against Ant 1.6.2
Comment 31 Jesse Glick 2005-01-28 04:41:34 UTC
It is now possible to distribute a patch (e.g. the previously attached
JAR) by including it in ide5/ant/patches/*.jar:

committed   * Up-To-Date  1.4         ant/arch/arch-ant-main.xml
committed   * Up-To-Date  1.22       
ant/src/org/apache/tools/ant/module/bridge/AntBridge.java
Comment 32 athompson 2005-01-28 14:45:09 UTC
cool! how would i patch my currently-running build?
Comment 33 Marek Grummich 2005-02-01 15:13:37 UTC
*** Issue 54024 has been marked as a duplicate of this issue. ***
Comment 34 Milan Kubec 2005-02-08 13:10:57 UTC
Works well with the patch. I suggest to distribute 4.1 with the patch
if Ant with patch included is not out in the time of NetBeans code freeze.
Comment 35 athompson 2005-02-08 13:16:17 UTC
i tried placing the attached jar into "ide5/ant/patches/", but it
didn't work. is there anything else i need to do?
Comment 36 Milan Kubec 2005-02-08 13:24:47 UTC
Did you use some recent build? And did you restart IDE? I just created
directory patches under ide5/ant, put the jar file there, started IDE
and then run project that required user input. And it worked for me.
Comment 37 athompson 2005-02-15 18:03:57 UTC
i got it to work. horray!

there is a problem with its operation, though. currently, any text on
the same line as where the input goes is not shown until after the
input. when the text is shown, the inputted text should be added but
it is not.

to better explain, consider this code:
  System.out.print("Enter your name: ");
  System.out.flush();
  BufferedReader in=new BufferedReader(
    newInputStreamReader(System.in)
  );
  String name=in.readLine().trim();
  System.out.println("Your name is " + name + "!");

when run the console, this is how it would look:
  Enter your name: Alvin
  Your name is Alvin!

when run in the IDE, there are a couple of problems. first, the "Enter
your name: " line is not displayed in the output window, so if your
program has several inputs you can forget which is which. second, when
the line is displayed the assumed newline is not added, so you wind up
with this:
  Enter your name: Your name is Alvin!

to fix this, please make sure all output is sent to the output window
before the input prompt comes up. also when the text is inputted, copy
the inputted text (plus a new-line) to the output window. that way it
will look/act the way it's supposed to.
Comment 38 Milos Kleint 2005-02-28 12:08:35 UTC
*** Issue 55157 has been marked as a duplicate of this issue. ***
Comment 39 Jesse Glick 2005-03-07 15:58:51 UTC
Alvin I filed your comments separately as issue #56070 since they are
 completely independent of this issue.

Following Milan's comments, planning to put the workaround patch into
4.1 unless there are objections. I do not expect a patched version of
Ant to be available in time, though who knows.
Comment 40 Jesse Glick 2005-03-10 15:50:15 UTC
Putting in the patch for 4.1.

committed   * Up-To-Date  1.102       ant/build.xml
committed   * Up-To-Date  1.9         ant/external/.cvsignore
added       * Up-To-Date  1.1         ant/external/24918.jar.scrambled
committed   * Up-To-Date  1.8         ant/external/build.xml
committed   * Up-To-Date  1.32        ide/golden/files-layout.txt
Comment 41 Marian Mirilovic 2005-03-11 06:28:15 UTC
*** Issue 56221 has been marked as a duplicate of this issue. ***
Comment 42 Milan Kubec 2005-03-14 11:00:24 UTC
Verified in dev-200503131900. 

Jesse, are there any tricks to look after?
Comment 43 pzgyuanf 2005-03-14 11:21:51 UTC
I'm not in the CC list now, but every time a new comment got I got one too.
How can I exit?

thanks

-pprun
Comment 44 zikmund 2005-03-14 12:22:08 UTC
You have the vote ... removing it should help ;-).
Comment 45 pzgyuanf 2005-03-14 12:29:50 UTC
zikmund, thanks for your hint.

-pprun
Comment 46 Jaroslav Pospisil 2005-03-14 13:48:12 UTC
Now waiting for commit to qbuild branch.
Comment 47 zikmund 2005-03-14 13:52:29 UTC
It is no more Q-build stopper. No need of Q-build branch integration.
Comment 48 Jesse Glick 2005-03-16 17:02:26 UTC
Ant #24918 was merged to the 1.6.x branch and so will go into the Ant 1.6.3
release (I hope). If that release is made (final, not RC!) in time for the NB
4.1 code freeze, then we will simply bundle 1.6.3 and drop the patch. Otherwise,
NB 4.1 will be released with 1.6.2 and the patch, and when 1.6.3 is released and
adequately tested with NB, we can distribute an update to the Ant module
including 1.6.3 (and no patch).

So something else to test - that NB 4.1 builds with the patch JAR deleted will
correctly handle console input if the Ant installation is switched (Ant
Settings) to a 1.6.3 release candidate or daily build or whatever. Seems to be
working for me in simple cases.
Comment 49 Jesse Glick 2005-03-21 10:37:50 UTC
*** Issue 56673 has been marked as a duplicate of this issue. ***
Comment 50 vanob 2005-03-23 15:04:26 UTC
I tested the patch with the q-build
200503150955 and have some feedback.
Is it correct to post it here?
Comment 51 Jan Chalupa 2005-03-23 15:20:15 UTC
Sure. However, it might be a good idea to test with the latest daily build or
wait for the next q-build. There have been a couple of additional changes since
20050315.
Comment 52 vanob 2005-03-23 15:31:42 UTC
I will wait for the next q-build
BTW when will it be approximately available?
netcat list is kind of quiet about the development activity.
Comment 53 Jan Chalupa 2005-04-01 16:51:42 UTC
*** Issue 57306 has been marked as a duplicate of this issue. ***
Comment 54 Jan Chalupa 2005-04-01 16:52:35 UTC
*** Issue 57306 has been marked as a duplicate of this issue. ***
Comment 55 Marian Mirilovic 2005-05-10 16:07:20 UTC
*** Issue 58737 has been marked as a duplicate of this issue. ***
Comment 56 rcking75 2005-06-27 17:07:59 UTC
If you are not happy with the output window not displaying your input prompt 
when testing your console apps please vote for issue #56070.
Comment 57 Jesse Glick 2006-01-22 16:46:17 UTC
*** Issue 22611 has been marked as a duplicate of this issue. ***
Comment 58 trinityalice2 2015-11-14 06:06:31 UTC
Every thing changed now and there is easy ways you can find on google. 
http://www.courseworkbox.co.uk
Comment 59 AimeeMoore 2016-10-19 05:44:40 UTC
It is no more Q-manufacture plug. No need of Q-manufacture branch incorporation. http://www.trueessayhelp.co.uk/
Comment 60 amandacernny 2016-11-02 11:26:42 UTC
Beyond any doubt. Notwithstanding, it may be a smart thought http://www.courseworklabs.co.uk/ to test with the most recent day by day construct or sit tight for the following q-assemble. There have been two or three extra changes since 20050315.
Comment 61 james621lara 2019-04-18 11:34:54 UTC
Thanks For sharing this information. It’s Nice..!!!
https://games.lol/