This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Getting NPE while using Console Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Getting NPE while using Console " Watch "Getting NPE while using Console " New topic
Author

Getting NPE while using Console

Rohan Kayan
Ranch Hand

Joined: Sep 17, 2004
Posts: 123
Hi, I am trying to run following code from Eclipse



Every time I am getting NullPointerException , what could be the issue ??


SCWCD 1.4, SCJP 1.4
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6588
    
    1

You cannot get a Console from eclipse. You can try out the examples from this article on your command line -> http://www.certpal.com/scjp-6-Console.html


SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
because in some jvm there may not be a console.
from K&B:
Keep in mind that it's possible for your Java program to be running in an environment that doesn't have access to a console object, so be sure that your invocation of System.console() actually returns a valid console reference and not null.


SCJP 1.6 96%
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6588
    
    1

because in some jvm there may not be a console.


To correct that a little, some JVM environments may not have a console
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting NPE while using Console
 
Similar Threads
Console class
web module of ear is not getting picked up by WL10.3.0.0
Problem with Junit control flow.
Problem with MessageFormat
Problems to use Console object on Java 6