This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Giving console arguments using Eclipse

 
shuba gopal
Ranch Hand
Posts: 76
  • 0
  • 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: 20380
45
Chrome Eclipse IDE Java Windows
  • 0
  • 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
  • 0
  • 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: 20380
45
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Scanner wrapped around System.in should work.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic