File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Command line IO Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Command line IO" Watch "Command line IO" New topic
Author

Command line IO

Michael Anderson
Greenhorn

Joined: Oct 19, 2007
Posts: 4
My Java Program is to be executed from the command line, reading and writing to/from the command window. It will prompt for SQL data connection parameters. Ea: Servername, Basename, Username, and Password.

java myjavaprog

Enter Server Name? myserver
Enter Database? mybase
Enter User name? me
Enter Password? symb0l1c

Q: When the user is typing the password into this character mode prompt, how do I (the programmer)turnoff the echo to the command window so that no one can see the password being typed by the user?

Thanks in Advance,
Mike.

With 1/4 century of programming experience, yet I am a Java Greenhorn.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

If you're using Java 1.6, take a look at java.io.Console. This has a method called readPassword() which turns off echoing.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Michael Anderson
Greenhorn

Joined: Oct 19, 2007
Posts: 4
Thanks! That is what I needed.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Command line IO
 
Similar Threads
Problem in Password encryption
JAR with no Command Prompt involved
Else without if error
Login Window in Html page Apache style
Code Help