• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Giving console arguments using Eclipse

 
Ranch Hand
Posts: 87
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 87
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A Scanner wrapped around System.in should work.
reply
    Bookmark Topic Watch Topic
  • New Topic