+ 2
If this virtual machine has a console then it is represented by a unique instance of this class which can be obtained by invoking theSystem.console() method. If no console device is available then an invocation of that method will return null.
If the virtual machine is started automatically, for example by a background job scheduler, then it will typically not have a console.
Copied from:
https://docs.oracle.com/javase/7/docs/api/java/io/Console.html