0

In my develope environment I have tomcat (9.0) with the System.out.autoflush off. How can I set it to on?

EDIT:

I tried to put thoose lines:

private static boolean autoflushSetted = false;
void systemOutPrintln(String str) {
  if (!autoflushSetted) {
    autoflushSetted = true;
    try {
      Field af = PrintStream.class.getDeclaredField("autoFlush");
      af.setAccessible(true);
      af.set(System.out, Boolean.TRUE);
    } catch (Throwable e) {
    }
  }
  System.out.println(str);
}

I tried also to set autoFlush via reflection to the result of the method findStream on System.out, and verified that the println flushed the writing, but countines to not work. Also setting the System.out to a new PrintStream (thanks to samabcde) does not work. It seems that the console window in Eclipse doesn't see that there was an output until the thread is completed. I can't see any setting to force the console windows to be smarter. Eclipse has this behaviour only when I run tomcat projects, instead standalone projects where it runs well. I cannot understand.

Lucio Menci
  • 133
  • 6

0 Answers0