• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Giving console arguments using Eclipse

 
shuba gopal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am learning to use the Eclipse IDE. I am using the console class to get an input. While running the program, I give the console input using the "Arguments\Program Arguments" tab. However I am still getting NPE. Do I need to do anything else? The programs runs fine as a text file.
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.console() only returns a non-null value if you run the application from an actual command line. IDEs like Eclipse don't have one, they just mimic one. However, that means that System.console() returns null. You can't prevent that. You'll just have to test your application from a good-old command prompt window.
 
shuba gopal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob,

Thanks. I am actually learning to use Eclipse after using Notepad for a long time. What else works with Eclipse if we need to get input from user?
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Scanner wrapped around System.in should work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic