File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Cannot get instance of Console Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Cannot get instance of Console" Watch "Cannot get instance of Console" New topic

Cannot get instance of Console

Sahil Manchanda
Ranch Hand

Joined: Jul 24, 2012
Posts: 41

my system is not providing me with an instance of console ... (Console s = System.console();).. what to do?
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 923

you are probably running your program in an IDE. try running your program in commandline and you will definitely get an instance of Console. for more information refer javadocs for Console class at

OCPJP 6(100 %) OCEWCD 6(91 %) OCPJBCD(93%)
Sahil Manchanda
Ranch Hand

Joined: Jul 24, 2012
Posts: 41

o yes i was .. thankyou!
Don Redd
Ranch Hand

Joined: Jan 05, 2012
Posts: 82

In extension to what gurpeet said. IDE's generally uses javaw.exe (which doesnt have a console associated) and not java.exe( which have a associated console)
I agree. Here's the link:
subject: Cannot get instance of Console
Similar Threads
Classes for printing into console
visual age use
Applet not running in Internet Explorer
Passing String array as argument to main() method