0

I'm trying to get the content of the console and append it to a JavaFX TextArea.
I've found various examples all around StackOverflow, but all of them use a similar code to this:

@FXML
public void initialize() throws IOException {
    Console console = new Console();
    PrintStream ps = new PrintStream(console, true);
    System.setOut(ps);
    System.setErr(ps);
    System.err.flush();
    System.out.flush();
}

The issue is that the first two lines don't seem to be anymore accepted in Java 9. For the first one, I've solved my problem like this:

Console console = new Console();

becomes...

Console console = System.console();

Still, the PrintStream constructor doesn't accept anymore a java.io.Console object as an input, but only...

Error:(124, 26) java: no suitable constructor found for PrintStream(java.io.Console,boolean) constructor java.io.PrintStream.PrintStream(boolean,java.io.OutputStream) is not applicable (argument mismatch; java.io.Console cannot be converted to boolean) constructor java.io.PrintStream.PrintStream(java.io.OutputStream,boolean) is not applicable (argument mismatch; java.io.Console cannot be converted to java.io.OutputStream) constructor java.io.PrintStream.PrintStream(java.lang.String,java.lang.String) is not applicable (argument mismatch; java.io.Console cannot be converted to java.lang.String) constructor java.io.PrintStream.PrintStream(java.io.File,java.lang.String) is not applicable (argument mismatch; java.io.Console cannot be converted to java.io.File)

Am I missing something?
For reference, I've used this question.

Davide3i
  • 1,035
  • 3
  • 15
  • 35
  • 2
    It's not `System.console()` you see in those examples, it's a [custom Console](https://stackoverflow.com/questions/17981938/how-to-make-custom-java-javafx-console?rq=1). – Kayaman Feb 20 '18 at 10:23
  • I'll have a look at that question. Thank you for pointing out the culprit. In any of the topic I've looked into was specified to use a Custom Console. – Davide3i Feb 20 '18 at 10:27

0 Answers0