File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Getting NPE while using Console Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
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: 6657
    
    5

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 - More SCJP Mocks
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: 6657
    
    5

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
Problem with Junit control flow.
Problem with MessageFormat
web module of ear is not getting picked up by WL10.3.0.0
Problems to use Console object on Java 6
Console class