To dig up a really old thread..... This is a definite hack, but workds. public class Eraser extends Thread { PrintStream out; boolean finish=false; public Eraser (PrintStream out) { this.out = out; } public void run () { while ( !finish ) { out.print ( "\010*" ); try { sleep ( 10 ); } catch ( InterruptedException inte ) { finish = true; } } } public static String readPassword () { Eraser eraser = new Eraser ( System.out ); eraser.start (); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String password = ""; try { password = in.readLine(); } catch ( IOException ioe ) { } eraser.interrupt (); try { Thread.sleep ( 100 ); } catch ( InterruptedException inte ) { } return password; } } > -----Original Message----- > From: tclug-devel-admin at mn-linux.org > [mailto:tclug-devel-admin at mn-linux.org] On Behalf Of Bob Tanner > Sent: Wednesday, January 16, 2002 2:40 AM > To: Mike Bresnahan > Cc: tclug-devel at mn-linux.org > Subject: Re: [TCLUG-DEVEL] Hidding passwords in Java? > > > Quoting Bob Tanner (tanner at real-time.com): > > Quoting Mike Bresnahan (mbresnah at visi.com): > > > This was asked recently on the TCJUG. Noone offered a solution > > > other than using JNI to call either getpass(3) or > tcsetattr(2). Me > > > thinks the Java designers decided that terminal I/O was > not part of > > > the least common demoninator. > > > > I've been messing around with the streams and experimenting with > > replacing System.in, but I can't keep the keystrokes from > appearing on > > the console. > > > > getpass(3) or tcsetattr(2) Eeek! I don't think those will > work under > > Losedows. > > > > Well, I got this working using JNI and tcsetattr(2). It was > actually very simple. > > Read the JNI stuff, it should be just as easy for someone to > write a windows DLL that does the same thing my share lib > does. Of course, that person will not be me, since I don't > have a Windows dev environment. > > I am actually very surprised how easy JNI makes hooking into > native code. > > -- > Bob Tanner <tanner at real-time.com> | Phone : (952)943-8700 > http://www.mn-linux.org, Minnesota, Linux | Fax : (952)943-8500 > Key fingerprint = 6C E9 51 4F D5 3E 4C 66 62 A9 10 E5 35 85 39 D9 > > _______________________________________________ > tclug-devel mailing list > tclug-devel at mn-linux.org > https://mailman.mn-linux.org/mailman/listinfo/tclug-devel