Reading password from Console in java -


i want read password console in 1 java program. used

 console newconsole = system.console(); 

but able declare , initialize console object in class. getting error message

" method console() undefined type system" , " console cannot resolved or not type" 

hence thought don't have latest java version , checked java version using

c:\>java -version     java version "1.7.0_21" 

i came know have java 1.7.0_21 latest version still getting error. please me regarding this.

if can't use system.console there other method can use read password hidden character console.

the complete code :

  import java.io.console;    public class test {       public static void main(string[] args) {              console newconsole = system.console();      }    } 

i getting compiler error in import java.io.console (java.io.console cannot resolved) , console newconsole = system.console(); (the method console() undefined type system , console cannot resolved or not type) line.

according javadoc:

whether virtual machine has console dependent upon underlying platform , upon manner in virtual machine invoked. if virtual machine started interactive command line without redirecting standard input , output streams console exist , typically connected keyboard , display virtual machine launched. if virtual machine started automatically, example background job scheduler, typically not have console.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -