Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to type in username and pw using Eclipse

 
Natasha Basu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not supported by Eclipse. Try it from the command line.

(next time UseCodeTags)
 
Natasha Basu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic