This change checks for the existence of System/console, and if it is null, it falls back on read-line. This allows it to run in environments where System/console doesn't exist, such as in the consoles inside IDEs. They typically work by running the code in a backend process and piping it to/from the GUI, so Java doesn't provide a Console object to them. Your password won't be hidden in this case, but at least it's better than getting a NullPointerException =)
This change checks for the existence of System/console, and if it is null, it falls back on read-line. This allows it to run in environments where System/console doesn't exist, such as in the consoles inside IDEs. They typically work by running the code in a backend process and piping it to/from the GUI, so Java doesn't provide a Console object to them. Your password won't be hidden in this case, but at least it's better than getting a NullPointerException =)