This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Console Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Console Class" Watch "Console Class" New topic
Author

Console Class

Mudit Srivastava
Ranch Hand

Joined: Apr 30, 2007
Posts: 38
Guys

I just can't figure out the Console Class.

Please help...
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
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


Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
You are reminded: Console will only work if you start your application from the command line with the java instruction.
Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
Campbell, that's only true for some OS right?


SCJA
~Currently preparing for SCJP6
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
Brian Legg wrote:Campbell, that's only true for some OS right?
Rob has provided a more accurate answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Console Class
 
Similar Threads
What is a Console class
Display
Classes for printing into console
Program for Console
Want to extend Console.