Hi all,

I am reading values (user name and password) from user's input, and I need to mask the password which is entered by user in the command line...

Can someone give me a hint which class do I need to look at?

Appreciate your inputs.


If you are using Java 1.6, the Console class provides a mechanism for this:

Thanks for reply,

Unfortunately I don't user Java 1.6, and Console doens't work for me.

I am using the follwoing code, but there's a minor issue with that. Can someone advise, please.

public void run () {
       stop = true;
       while (stop) {
     try {
          } catch(InterruptedException ie) {

This is just a snipt of the code, which masks the user's input to asktrisks.

When I run my program from within Eclipse IDE, and before the user gets prompted to enter a password, it goes to an infinit loop. However, when I run my program from a command prompt, like

C:>java Myprogram.java

Then it's ok. Can someone please advise...


This article has been dead for over six months. Start a new discussion instead.