• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error in using Console  RSS feed

 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting following exception in running this simple code
"Exception in thread "main" java.lang.NullPointerException
at objectTest.ConsoleTest.main(ConsoleTest.java:18)"

Whats wrong in here ?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Exception in thread "main" java.lang.NullPointerException
at objectTest.ConsoleTest.main(ConsoleTest.java:18)"

nirjari patel wrote:Whats wrong in here ?

The code you posted does not have line number 18
 
Tim Cooke
Marshal
Posts: 3840
221
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.console(); must be returning null.

It can do that: http://docs.oracle.com/javase/6/docs/api/java/lang/System.html#console%28%29
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!