0

Reproducible on both Netbeans & IntelliJ IDEA.

Basically, if I were to create a simple main program like this

public static void main(String[] args) {  System.out.print("Hello World"); }    

and run it on Netbeans/IntelliJ with Gradle. It won't work print out in both Netbeans & IntelliJ IDEA when I'm using Gradle. Not even System.out.flush() will help too.

Problem is, I'm creating a console-based application and I want to accept user's input on the same line. This does NOT happen in Ant/Maven, and only happens in Gradle.

Any suggestions or workarounds?

Thank you.

Linked to: Gradle print vs println and https://discuss.gradle.org/t/gradle-print-vs-println/21334/3 , but so far, no solutions on both threads

EDIT: Fixed in IntelliJ IDEA 2020.1, however, still not fixed in Netbeans 12.0

deleTe
  • 5
  • 4
  • I don't know about Netbeans, but which version of IntelliJ are you on? There is a [bug report](https://youtrack.jetbrains.com/issue/IDEA-184090) for it with a [fix](https://github.com/JetBrains/intellij-community/commit/707cf1427f66beb24faa5b8193217e52a8bb85d1) in version 2020.1. – Bjørn Vester Jul 22 '20 at 11:21
  • I'm in IDEA 2019, and yes updated it to 2020, and seems to have fixed the issue, thanks!. However, Netbeans is still broken though (and since its the main IDE used here, its problematic). – deleTe Jul 23 '20 at 01:10
  • [1] Provide more detail on the _exact_ problem you are facing; _"It won't work"_ is just too vague. [2] There were some known issues for a similar problem on NetBeans 11.1, but they were supposedly fixed in NetBeans11.2, and printing.scanning for a Gradle project works fine for me on NetBeans 12. [3] [This answer to a similar issue](https://stackoverflow.com/a/58293259/2985643) may be relevant. In particular, note that it is crucial to specify `run{ standardInput = System.in}` in your **build.gradle** file when accepting input to avoid `NoSuchElementException`. Are you doing that? – skomisa Jul 24 '20 at 22:03
  • Hi, yes, I'm doing that. This issue has been raised here: https://issues.apache.org/jira/browse/NETBEANS-4617. Basically, stdout is not being flushed until a newline is detected. Not even System.out.flush() will help too. – deleTe Jul 25 '20 at 00:37
  • OK. From the bug report you linked to, it seems that the NetBeans Team accept that there is an issue here (_"right now that's how the output processing works"_), so the only true resolution is a fix to NetBeans (and/or the plugin). – skomisa Jul 25 '20 at 18:39
  • True that. A fix has been proposed for Netbeans 12.2: https://github.com/apache/netbeans/pull/2270 . Would be nice if there's a "hack" or "workaround" in the meantime though. – deleTe Jul 27 '20 at 00:46

0 Answers0