• 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

Problems with instantiating a File object from text.txt put in at args[0]

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
This should be really basic, Just passing one file (in my project folder, triple checked that) into command line at args[0]

receiving error

The line in question is File f.... Any ideas? Suggestions?



Sincerely Stuck,
J
 
Sheriff
Posts: 22791
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You obviously didn't provide any command line arguments to the Java program.
 
Jai Gates
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is I did everything that would indicate that I did. Went into Netbeans project properties, selected it as my main class, selected myText.txt as my only argument, and pressed ok.

Checked a few times to make sure the text name is correct and the text file is in project folder so don't have to specify pathname in argument.
 
Jai Gates
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even tried specifying absolute path in argument. Will try from command line too to see if something having to do with netbeans.
 
Jai Gates
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happened:

I got a 0 return in Netbeans for S.O.P(args.length); and a 1 return at command line for S.O.P(for args.length);



So it was being passed in at command line and not at Netbeans. Strange.


Finally figured out that right clicking and running one class in a project, *even* if others not connected in any way, does not give you the same results as right clicking and running the main project.

When I did the latter, I got the a 1 output in Netbeans.

*whew* ...at this rate...

Thanks.

-J
 
Rob Spoor
Sheriff
Posts: 22791
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm glad you found the answer
 
Marshal
Posts: 79508
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not convinced that using NetBeans or return values from exit are the best way to program if you are a beginner.
reply
    Bookmark Topic Watch Topic
  • New Topic