System.console () returns null from Eclipse, but fine with the command line

When I use System.console from Eclipse Helios, it always returns null.

However, when I use it directly from the command line (i.e., compiling and running java source code manually from the command line), I get a console object.

To find out why this is happening, I checked this link. Accordingly, when I run my Java code from Eclipse, the background task scheduler should start my JVM. What does it mean?

And how does my JVM start differently when I start it from the command line?

I also checked this link. Here, McDowell says cmd.exe is a console device. So, I got confused again, what exactly is a console device?

+6
source share
2 answers

Because it's a bug # 122429 eclipse

+6
source

System.console() returns null if there is no console.

You can work around this either by adding an indirect layer to your code or by running code on an external console and with a remote debugger .

Also according to docs :

If the virtual machine starts automatically, for example, using the background task scheduler, then usually there will be no console.

+2
source

Source: https://habr.com/ru/post/906646/


All Articles