aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Giving console arguments using Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Giving console arguments using Eclipse" Watch "Giving console arguments using Eclipse" New topic
Author

Giving console arguments using Eclipse

shuba gopal
Ranch Hand

Joined: May 12, 2011
Posts: 76
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

Joined: Oct 27, 2005
Posts: 19697
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
shuba gopal
Ranch Hand

Joined: May 12, 2011
Posts: 76
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

Joined: Oct 27, 2005
Posts: 19697
    
  20

A Scanner wrapped around System.in should work.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Giving console arguments using Eclipse