• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Console Class

 
Mudit Srivastava
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys

I just can't figure out the Console Class.

Please help...
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I don't understand the use of a class in the standard library, the first thing I do is see if Sun had the wisdom to provide a tutorial, site:java.sun.com java.io.Console tutorial. In this case, they have
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are reminded: Console will only work if you start your application from the command line with the java instruction.
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell, that's only true for some OS right?
 
Rob Spoor
Sheriff
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.console() will return null if no console is available, and that is always the case if started using javaw or from most IDEs. Therefore, always perform the check against null.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian Legg wrote:Campbell, that's only true for some OS right?
Rob has provided a more accurate answer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic