java.io.Console when debugging in Eclipse

2

I'm trying to use the java.io.Console from within of Eclipse. However, whenever I call System.console () returns me null.

In jetty, you can pass parameters in the eclipse console. For example, if I press 'x' on the eclipse console, the jetty is terminated.

Does anyone know how to get it to consider the view Eclipse Console as a console for java in debug mode?

    
asked by anonymous 19.05.2016 / 03:19

1 answer

2

System.console () does not work in eclipse because in fact, even though there is a view called console, it is not actually a console. If you run the same code via terminal, it will work.

This issue is discussed here: link

You can use this here:

Scanner scanner = new Scanner(System.in);
String content = scanner.nextLine();
System.out.println("O contéudo lido foi: "+content);
scanner.close();

The Eclipse view console is accessed through System.in and System.out.

    
29.07.2016 / 15:00