Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Masking command line input  RSS feed

 
shah_ch
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Experts,

I would like to know is there a way to mask a password in java, entered using command line argument.

I tried the following piece of code





It always goes into an infinite loop as soon as it gets executed.

Could any one let me know what is wrong with this code and provide a better solution to mask the command line argument.

Thanks
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only way I know of that will achieve something similar, is to use the java.io.Console class added in 1.6.
It provides you with a readPassword() method that disables the local echo when a user enters the password.
Not quite the same thing, I know, but I think that's as close as you're going to get.
 
shah_ch
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for your reply.

I'm using JDK 1.5. So, I would like to know is there a way to achieve password masking in 1.5.
 
Adam Michalik
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you searched first? I found at least one solution for Java 5 on the "Java in General" forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!