• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to type in username and pw using Eclipse

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic