kelemen / netbeans-gradle-project

This project is a NetBeans plugin able to open Gradle based Java projects. The implementation is based on Geertjan Wielenga's plugin.
172 stars 57 forks source link

Issue with System.out.print #384

Open qcsoftware513 opened 6 years ago

qcsoftware513 commented 6 years ago

Small issue...when using System.out.print() I do not see the output in the console until a new line is printed. In the below example, I don't see abc print out until after the sleep command completes.

public class NBTest { @SuppressWarnings("unused") private static final String svnid = "$Id$";

public static void main(String[] args) { System.out.println("123456"); System.out.print("abc"); try { Thread.sleep(5000); } catch(InterruptedException ex) { ex.printStackTrace(); } System.out.println("123"); } }

This is causing issues because the System.out.print in my application displays a prompt and then the program waits for user input. I can type in the input and everything works, but then i don't see the prompts which can be confusing. Maybe I am missing a setting.

Thanks!

david-hall commented 6 years ago

Try using System.out.flush() after System.out.print().

System.out.println() includes the call to flush(). print() doesn't.

On Fri, May 25, 2018 at 10:24 AM, qcsoftware513 notifications@github.com wrote:

Small issue...when using System.out.print() I do not see the output in the console until a new line is printed. In the below example, I don't see abc print out until after the sleep command completes.

public class NBTest { @SuppressWarnings https://github.com/SuppressWarnings("unused") private static final String svnid = "$Id$";

public static void main(String[] args) { System.out.println("123456"); System.out.print("abc"); try { Thread.sleep(5000); } catch(InterruptedException ex) { ex.printStackTrace(); } System.out.println("123"); } }

This is causing issues because the System.out.print in my application displays a prompt and then the program waits for user input. I can type in the input and everything works, but then i don't see the prompts which can be confusing. Maybe I am missing a setting.

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kelemen/netbeans-gradle-project/issues/384, or mute the thread https://github.com/notifications/unsubscribe-auth/AKcyCl3UaibnY-gdby-zR6nHvtien8JAks5t2BQCgaJpZM4UOETp .

qcsoftware513 commented 6 years ago

That did not help. Same behavior.

Mike

From: David Hall [mailto:notifications@github.com] Sent: Friday, May 25, 2018 11:50 AM To: kelemen/netbeans-gradle-project netbeans-gradle-project@noreply.github.com Cc: Mike Billman mikebillman@qcsoftware.com; Author author@noreply.github.com Subject: Re: [kelemen/netbeans-gradle-project] Issue with System.out.print (#384)

Try using System.out.flush() after System.out.print().

System.out.println() includes the call to flush(). print() doesn't.

On Fri, May 25, 2018 at 10:24 AM, qcsoftware513 notifications@github.com<mailto:notifications@github.com> wrote:

Small issue...when using System.out.print() I do not see the output in the console until a new line is printed. In the below example, I don't see abc print out until after the sleep command completes.

public class NBTest { @SuppressWarnings https://github.com/SuppressWarnings("unused") private static final String svnid = "$Id$";

public static void main(String[] args) { System.out.println("123456"); System.out.print("abc"); try { Thread.sleep(5000); } catch(InterruptedException ex) { ex.printStackTrace(); } System.out.println("123"); } }

This is causing issues because the System.out.print in my application displays a prompt and then the program waits for user input. I can type in the input and everything works, but then i don't see the prompts which can be confusing. Maybe I am missing a setting.

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kelemen/netbeans-gradle-project/issues/384, or mute the thread https://github.com/notifications/unsubscribe-auth/AKcyCl3UaibnY-gdby-zR6nHvtien8JAks5t2BQCgaJpZM4UOETp .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/kelemen/netbeans-gradle-project/issues/384#issuecomment-392101075, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMLHp-YnFfdCXwZGP6WJCLdPMhTJd0mxks5t2Cg-gaJpZM4UOETp.

kelemen commented 6 years ago

I don't output anything before receiving a line ending to analyze a full line if something has to be turned into a link. I can't really remember but I think Gradle also won't send it back before a new line is emitted (not sure about this last one though).

qcsoftware513 commented 6 years ago

Any thoughts as to how I might get around this?

kelemen commented 6 years ago

I think currently the only way to get around this is to start Gradle from the terminal (even if it is the terminal of NB). I have checked and it seems that Gradle does send back the output so it is solvable on my side, assuming I do something with the problem that then I can't easily analyze a line to provide links. I could provide some timeout (configurably) but I guess that would still be very annoying. Or I could provide a configuration which disables analyzing lines (and you won't get links in the output window) but would see the output immediately. What would be an adequate workaround for you?

kelemen commented 6 years ago

I looked around the NB API if I could remove the last output line (so that I could print it after checking for links) but had no success even with dirty reflection hacks. So, the only possibilities I can imagine are the ones I have already listed.

qcsoftware513 commented 6 years ago

One of the reasons I like the output window is the ability to get links. 99% of the time, I won’t have output that doesn’t have a new line at the end of it. This basically only happens when we are doing testing through the application with programmer input. In brief, our application would run without any user input in a production setting. In a test mode, we can trigger a series of inputs to test a specific scenario. It is these inputs that output data without a new line. So I think a configurable timeout would be fine for my use case.

Mike

From: Attila Kelemen [mailto:notifications@github.com] Sent: Monday, June 4, 2018 3:46 PM To: kelemen/netbeans-gradle-project netbeans-gradle-project@noreply.github.com Cc: Mike Billman mikebillman@qcsoftware.com; Author author@noreply.github.com Subject: Re: [kelemen/netbeans-gradle-project] Issue with System.out.print (#384)

I looked around the NB API if I could remove the last output line (so that I could print it after checking for links) but had no success even with dirty reflection hacks. So, the only possibilities I can imagine are the ones I have already listed.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/kelemen/netbeans-gradle-project/issues/384#issuecomment-394475563, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMLHp-tyHeUkQrjy1nAnQyT3HphW823Aks5t5Y5ygaJpZM4UOETp.

kelemen commented 6 years ago

I will see to implement it after #386 is settled in some form to make merging easier (it is quite annyoing to merge this branch after changes of these kinds into nb9 due to the large number of changes).

qcsoftware513 commented 6 years ago

Thanks.

Mike

From: Attila Kelemen [mailto:notifications@github.com] Sent: Thursday, June 7, 2018 2:51 PM To: kelemen/netbeans-gradle-project netbeans-gradle-project@noreply.github.com Cc: Mike Billman mikebillman@qcsoftware.com; Author author@noreply.github.com Subject: Re: [kelemen/netbeans-gradle-project] Issue with System.out.print (#384)

I will see to implement it after #386https://github.com/kelemen/netbeans-gradle-project/issues/386 is settled in some form to make merging easier (it is quite annyoing to merge this branch after changes of these kinds into nb9 due to the large number of changes).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/kelemen/netbeans-gradle-project/issues/384#issuecomment-395526477, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMLHp1TjE-34lo5WiTHZG6kwBtgDTu0Tks5t6XYUgaJpZM4UOETp.