• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Console typing of password

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I need to accept a password from console using streams.but the password characters should be displayed as * or space.How is it possible?

Regards
Rajasree
 
Ranch Hand
Posts: 657
Spring VI Editor Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://java.sun.com/features/2002/09/pword_mask.html

Regards...
 
Rajasree R
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thank you very much.
But I have a small problem.If I am running the example programs from the command prompt its working fine.But when I am running from eclipse its printingn the prompt continuously.
One another similar program which I got is here.
If I run this from eclise and enter any key in console the eclipse window will get closed.Why is it so?
The code is here:

import java.io.*;
import java.awt.*;

public class PwdConsole {
public static void main(String[] args) throws Exception {
ConsoleEraser consoleEraser = new ConsoleEraser();
System.out.print("Password? ");
BufferedReader stdin = new BufferedReader(new InputStreamReader(
System.in));
consoleEraser.start();
String pass = stdin.readLine();
consoleEraser.halt();
System.out.print("\b");
System.out.println("Password: '" + pass + "'");
}
}

class ConsoleEraser extends Thread {
private boolean running = true;

public void run() {
while (running) {
System.out.print("\b ");

}
}

public synchronized void halt() {
running = false;
}
}




Regards
Rajasree
 
Ranch Hand
Posts: 472
Objective C Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can try (I didn't yet) to run another Java application for entering password. Since you have controls over in and out of such application, you can easily to block displaying any inputs. If you implement my approach, please share code and origin of the idea.
 
Rajasree R
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In the link suggested by Mr.Steve Morrow
http://java.sun.com/features/2002/09/pword_mask.html the examples are like that.
But in that case also when I run it from eclipse its printing the prompt continuously,though it wont close the eclispe window as in the previous program(PwdConsole)

In commoand prompt all these are working fine.Any solution?
Regards
Rajasree
 
So there I was, trapped in the jungle. And at the last minute, I was saved by this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic