java.io.Console when debugging in Eclipse

Asked

Viewed 86 times

2

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

In Jetty, it is possible to pass parameters on the eclipse console. For example, if I press 'x' on the eclipse console, Jetty is finished.

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

1 answer

2


System.console() does not work at eclipse because in fact, although you have a view called console, it is not considered a console at all. If you run the same code via terminal, it will work.

That question is discussed here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=122429

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 console view is accessed through System.in and System.out.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.