How to insert mask " * " for a password when entering data in java?

I want mask user input for a password field in java, can anyone help??

here r my codes....

import java.sql.*;
import java.io.* ;


public class OrderProcessing {

String ans;
int choice;
static String use1;
static String pass1;

BufferedReader br= new BufferedReader (new InputStreamReader(System.in));


      public void LogInMenu() throws IOException, SQLException{

      int counter=0;

      Statement stmt ;
      ResultSet rs ;
      PreparedStatement pstmt ;
      String query;

      Connect connect1=new Connect();
      stmt=connect1.connect.createStatement() ;

            System.out.print("================================================================================");
            System.out.print("\t\tMAURIWEAR ORDER PROCESSING SYSTEM LOG IN MENU");
            System.out.print("\n================================================================================");


            while (counter<3)
            {
            //for (int i=0; i<5; i++)
          //System.out.println("\n");

            if (counter==0)
            System.out.print(counter+1+ "st Try");
            else if (counter==1)
            System.out.print(counter+1+ "nd Try");
            else
            System.out.print(counter+1+ "rd Try");

            System.out.print("\t\t\tUser Name: ");
            String UserName=br.readLine();

            System.out.print("\n\t\t\tPassword: ");
            String Password=br.readLine();


            query = "select EmployeeID from Employee where UserName+Password ='"+ UserName + Password+"'";

          rs = stmt.executeQuery(query) ;

          if (rs.next())
          {      use1=UserName;
                pass1=Password;
                  mainmenu();
            }
            rs.close() ;

            System.out.print("\n\t\tYou are not an Authorised Employee!!!!\n");
            System.out.print("\n================================================================================");
            counter=counter+1;

            }

      }

public static void main(String args[]) throws Exception
      {
            OrderProcessing Ord=new OrderProcessing();

            Ord.LogInMenu();

      }
}
SniperVishalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RuadRauFlessaCommented:
In console Mode you must be off your rocker. There are not go to commands or anything in Java. People fail to grasp the concept that console output is supposed to be for debugging only. Not for actually accepting user input or giving user output. Go over to Swing or AWT and your problem will be solved. There is even a component specially designed for accepting passwords (JPasswordField) they even took a couple of precautions to make sure that someone who is listening for memory changes cannot readily and without any hassle blindly just read the damn value.
0
SniperVishalAuthor Commented:
I tried the method objects said... its seems nice but the user wont know he is typing.... anyways it does the job..
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

objectsCommented:
yeah its a bit of a hack, but its the best u can do
0
objectsCommented:
try replacing the print in the thread with:

System.out.print("\010*");
0
RuadRauFlessaCommented:
Nice one objects.
0
girionisCommented:
I think points should be split between me and objects.
0
RuadRauFlessaCommented:
I would agree with girionis on that.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.