Hii all,

Using Scanner class I am accepting an input string which serves as a password field

Is it possible to mask the field while the input is being given ??

eg: This is how my output will be :

Username : abcde1
Password : abcd@xyz

This inputs are given using ScannerObject.nextLine()
Can I mask the password input ??

Help me regarding this plz..

@masijade

I tried console but the object for console class is not getting created !! I am using Dr.Java IDE to run the java source file.. I heard that console doesnt work for IDE's

Is there any other solution plz ..?

Run it from the command line. After all, are you planning on deploying the IDE along with the application?

Edited 6 Years Ago by masijade: n/a

No.. The IDE is the only thing that I am supposed to use
This is the task given to me and i have to run the application on the same IDE
But i m not finding the solution for the problem

Then you can't. Maybe using Runtime.exec/ProcessBuilder to run some external command, but that's a brain-dead platform dependent hack.

And, if the instructor is truely saying that you must develop and execute from an IDE then he is doing the class an injustice. You will not learn the language and everything that goes into properly if you never learn how to compile, execute, package, deploy, manipulate the classpath, and make adjustments to the JVM from the command line. You will simply become a code-monkey that becomes almost useless as soon as you don't have that IDE in front of you.

The only other way is to use a Swing GUI and not a command line and the JPasswordField.

This article has been dead for over six months. Start a new discussion instead.