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.
Summary: | [40cat] Cannot send console input to running app | ||
---|---|---|---|
Product: | projects | Reporter: | Milan Kubec <mkubec> |
Component: | Ant | Assignee: | 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
Hmm, looks like someone noticed. 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. 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. 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. Oops I did it again. The last comment is about another issue. 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. 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. More descriptive summary. Still up in the air whether and how this can be resolved for 4.0; might not need waiving. *** Issue 48729 has been marked as a duplicate of this issue. *** 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 *** Issue 49384 has been marked as a duplicate of this issue. *** Ok, then how do I run a Java app in unforked mode? Please help me! Thanks in advance. Gerson. 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. *** Issue 50420 has been marked as a duplicate of this issue. *** *** Issue 50420 has been marked as a duplicate of this issue. *** *** Issue 50419 has been marked as a duplicate of this issue. *** Still no known good workaround in 4.0; will still try to fix in Ant itself. *** Issue 50773 has been marked as a duplicate of this issue. *** *** Issue 51301 has been marked as a duplicate of this issue. *** *** Issue 50064 has been marked as a duplicate of this issue. *** *** Issue 52140 has been marked as a duplicate of this issue. *** *** Issue 52234 has been marked as a duplicate of this issue. *** *** Issue 52234 has been marked as a duplicate of this issue. *** *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. Distributing a patched Ant to solve this issue has been considered as an option. 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... 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. 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. Created attachment 20023 [details]
Patch JAR against Ant 1.6.2
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 cool! how would i patch my currently-running build? *** Issue 54024 has been marked as a duplicate of this issue. *** 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. i tried placing the attached jar into "ide5/ant/patches/", but it didn't work. is there anything else i need to do? 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. 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. *** Issue 55157 has been marked as a duplicate of this issue. *** 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. 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 *** Issue 56221 has been marked as a duplicate of this issue. *** Verified in dev-200503131900. Jesse, are there any tricks to look after? 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 You have the vote ... removing it should help ;-). zikmund, thanks for your hint. -pprun Now waiting for commit to qbuild branch. It is no more Q-build stopper. No need of Q-build branch integration. 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. *** Issue 56673 has been marked as a duplicate of this issue. *** I tested the patch with the q-build 200503150955 and have some feedback. Is it correct to post it here? 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. 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. *** Issue 57306 has been marked as a duplicate of this issue. *** *** Issue 57306 has been marked as a duplicate of this issue. *** *** Issue 58737 has been marked as a duplicate of this issue. *** If you are not happy with the output window not displaying your input prompt when testing your console apps please vote for issue #56070. *** Issue 22611 has been marked as a duplicate of this issue. *** Every thing changed now and there is easy ways you can find on google. http://www.courseworkbox.co.uk It is no more Q-manufacture plug. No need of Q-manufacture branch incorporation. http://www.trueessayhelp.co.uk/ 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. Thanks For sharing this information. It’s Nice..!!! https://games.lol/ |