Home > Enterprise >  how to hide password while typing in console in java
how to hide password while typing in console in java

Time:05-26

I am developing a online order management system in java connecting MySql to run in console where I need to login using userid and password. so, here I need to mask the password while typing in console. can anyone pls, help me with this?

CodePudding user response:

The class Console has a method readPassword() that might be helpful in your case.

CodePudding user response:

char[] password = System.console().readPassword("password:");

notice: you can't run this code in IDE, you have to execute on terminal.

  • Related