Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

something wrong with null exception in I/O processing  RSS feed

 
John Batista
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a code that should've worked, but didn't


What's the problem? thanks
 
Stephan van Hulst
Saloon Keeper
Posts: 6966
109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
c is null. System.console() doesn't return a console in your case.

John, next time please post actual code, instead of screenshots. It makes it easier for us to help you, and it reduces bandwidth needed.
 
John Batista
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so how do I make the console not null? thanks
 
Stephan van Hulst
Saloon Keeper
Posts: 6966
109
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By running your program from the command line, instead of from Eclipse.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan is right. System.console() only returns a non-null value if it's actually run from the console. IDE's like Eclipse try to emulate a console but this is not the same, and therefore System.console() returns null.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!