Turning echo off in Java

C

ctippur

Hi all,

I would like to prompt the user for a password and turn off echoing
what the user inputs ("stty echo off" command in unix). Is this
possible in Java?
I really appreciate any input.

Thanks,
Shekar Tippur
 
T

Tim Slattery

Hi all,

I would like to prompt the user for a password and turn off echoing
what the user inputs ("stty echo off" command in unix). Is this
possible in Java?

Huh? This is a programming language, not an OS shell. It doesn't write
anything out unless you tell it to.
 
T

Thomas G. Marshall

Tim Tyler coughed up:
It does when reading characters on the command line.

I think the OP is looking for:

http://java.sun.com/features/2002/09/pword_mask.html


It's entirely possible that the OP was looking for something non-command
line based, but didn't know how to ask for it in swing/awt/etc.

But in any case, I think that the solution you provided is both clever *and*
hysterical!

You gotta love the heroic leaps of effort that you can find here and there.



--
Puzzle: You are given a deck of cards all face down
except for 10 cards mixed in which are face up.
If you are in a pitch black room, how do you divide
the deck into two piles (may be uneven) that each
contain the same number of face-up cards?
Answer (rot13): Sebz naljurer va gur qrpx, qrny bhg
gra pneqf naq syvc gurz bire.
 
T

Tim Tyler

Thomas G. Marshall said:
Tim Tyler coughed up:

It's entirely possible that the OP was looking for something non-command
line based, but didn't know how to ask for it in swing/awt/etc.

The URL covers that too:

``If you wish to provide a graphical login dialog box for your
application, you can use the AWT's TextField class, which is a text
component that allows editing of a single line of text. To mask the
password field, use the setEchoChar method. For example, to set the
echo char to an asterisk, you would do the following:

TextField password = new TextField(8);
password.setEchoChar('*');''

There's also a Swing version.
But in any case, I think that the solution you provided is both clever *and*
hysterical!

It's a real problem for those writing command line tools in Java.

Echoing passwords to the screen is simply not normally acceptable.

It's good that there's a way around the problem - even if it is ridiculous.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top