Hi
I am using Eclipse and i am not able to get the appropriate results for the following program from
SCJP guide by Rassmussen
package com.general5;
import java.io.Console;
public class ConsoleInput {
public static void main(
String[] args) {
// TODO Auto-generated method stub
Console console = System.console();
if (console == null) {
System.err.println("No console available");
return;
}
String username = console.readLine("Enter user name(%d chars): ", 4);
char[] password = console.readPassword(
"Enter the password (%d chars): ", 4);
System.out.println("Username: " + username);
System.out.println("Password: " + String.valueOf(password));
}
}
The output for this program says
No console available. The
IDE is not able to make the program prompt for the user name and password. I am missing something. Can somebody tell me what it is?
Thank in advance.