aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes How to type in username and pw using Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "How to type in username and pw using Eclipse" Watch "How to type in username and pw using Eclipse" New topic
Author

How to type in username and pw using Eclipse

Natasha Basu
Greenhorn

Joined: Nov 21, 2008
Posts: 10
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

This is not supported by Eclipse. Try it from the command line.

(next time UseCodeTags)


[My Blog]
All roads lead to JavaRanch
Natasha Basu
Greenhorn

Joined: Nov 21, 2008
Posts: 10
Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to type in username and pw using Eclipse