0

I'm trying to build a command line application where a user will be asked for their name and password but I want to mask the password using '*'. I looked into many posts and saw many of them using System.console() to use the readpassword() functionality, however, in the IDE environment, System.console() returns null and thus my program crashes. How can I overcome this? I want to be able to read the password without displaying what the user is actually typing in.

Edit: The other posts that I've read Link addressed this issue but the solution seems unclear to me.

Any form of help will be appreciated. Thank you.

Ava-123
  • 3
  • 3
  • Possibly related: [Trying to read from the console in Java](https://stackoverflow.com/q/26470972). – Pshemo Oct 13 '22 at 16:48
  • Anyway if you are creating console application my guess is that you will be *running* it through console where `System.console()` will not return `null` but valid Console object. In case of IDE you can't do much, unless you know how to run your code via `java.exe` instead of `javaw.exe` (which I don't so can't help you with this). – Pshemo Oct 13 '22 at 16:52

0 Answers0