This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Console Class" Watch "Console Class" New topic

Console Class

Mudit Srivastava
Ranch Hand

Joined: Apr 30, 2007
Posts: 38

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, 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

Joined: Oct 13, 2005
Posts: 43968
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?

~Currently preparing for SCJP6
Rob Spoor

Joined: Oct 27, 2005
Posts: 20078

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.

How To Ask Questions How To Answer Questions
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 43968
Brian Legg wrote:Campbell, that's only true for some OS right?
Rob has provided a more accurate answer.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Console Class
It's not a secret anymore!