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* ;

public class OrderProcessing {

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

BufferedReader br= new BufferedReader (new InputStreamReader(;

      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("\t\tMAURIWEAR ORDER PROCESSING SYSTEM LOG IN MENU");

            while (counter<3)
            //for (int i=0; i<5; i++)

            if (counter==0)
            System.out.print(counter+1+ "st Try");
            else if (counter==1)
            System.out.print(counter+1+ "nd Try");
            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 (
          {      use1=UserName;
            rs.close() ;

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



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


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
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.
SniperVishalAuthor Commented:
I tried the method objects said... its seems nice but the user wont know he is typing.... anyways it does the job..
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.

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

Nice one objects.
I think points should be split between me and objects.
I would agree with girionis on that.
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

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.