System.console() writes to stderr when stdout is redirected

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P2
    • 23
    • Affects Version/s: 22, 23
    • Component/s: tools
    • None
    • 22
    • b22
    • Verified

      Having code like:

      ---
      public class ConsoleTest {
          public static void main(String... args) {
              System.console().readLine("Hello!");
          }
      }
      ---

      And running it like:

      ---
      $ ~/tools/jdk/jdk-22/bin/java /tmp/ConsoleTest.java >/dev/null
      Hello!
      ---

      Obviously, the text has not been written to stdout, but rather was (presumably) written to stderr.

            Assignee:
            Jan Lahoda
            Reporter:
            Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: