• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Jai Gates
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm glad you found the answer
 
Campbell Ritchie
Marshal
Posts: 55768
163
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!