Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » FileNotFound(FileNotFound)
FileNotFound [message #1010174] Sat, 16 February 2013 19:34 Go to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
I am trying to access a file in the source folder. When I use another editor with the same code, it works. I cannot find a reason it does not in Eclipse. All of my other code works. I have tried other files without success. I unistalled & reinstalled Eclipse. It still does not work.
Any Suggestions?

Exception in thread "main" java.io.FileNotFoundException: mobydick.txt (The syst
em cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.util.Scanner.<init>(Unknown Source)
at HWo5Main.main(HWo5Main.java:17)


Exception in thread "main" java.io.FileNotFoundException: Numbers.txt (The syste
m cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.util.Scanner.<init>(Unknown Source)
at WrapperClass.readFile(WrapperClass.java:32)
at CH10Main.main(CH10Main.java:22)

Any help would be appreciated.
Re: FileNotFound [message #1010248 is a reply to message #1010174] Sun, 17 February 2013 01:00 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 02/16/2013 02:37 PM, Sally Budack wrote:
> I am trying to access a file in the source folder. When I use another
> editor with the same code, it works. I cannot find a reason it does not
> in Eclipse. All of my other code works. I have tried other files
> without success. I unistalled & reinstalled Eclipse. It still does not
> work. Any Suggestions?
>
> Exception in thread "main" java.io.FileNotFoundException: mobydick.txt
> (The syst
> em cannot find the file specified)
> at java.io.FileInputStream.open(Native Method)
> at java.io.FileInputStream.<init>(Unknown Source)
> at java.util.Scanner.<init>(Unknown Source)
> at HWo5Main.main(HWo5Main.java:17)
>
>
> Exception in thread "main" java.io.FileNotFoundException: Numbers.txt
> (The syste
> m cannot find the file specified)
> at java.io.FileInputStream.open(Native Method)
> at java.io.FileInputStream.<init>(Unknown Source)
> at java.util.Scanner.<init>(Unknown Source)
> at WrapperClass.readFile(WrapperClass.java:32)
> at CH10Main.main(CH10Main.java:22)
>
> Any help would be appreciated.


Your question is a bit misleading. In fact, you're not trying to open a
file with an editor, but from code you've written in Java, no? The fact
that you can use an editor to open the file successfully is neither here
nor there (apples and oranges).

This is really more a Java--not Eclipse--question. As such, you should
ask it in a Java forum like javaranch.com, jguru.com or
stackoverflow.com. Or Google for the answer.

What you're missing, however, is an understanding of how the path works
relative to, in this case an Eclipse project, but it's a similar problem
no matter what IDE you're using (or even with no IDE at all).

For many reasons, Java is a lot harder to use for file I/O than what
other languages like C offer. If you were to move mobydick.txt to
C:\eclipse (or wherever you've installed Eclipse) or to the root of your
project, you'd probably find that your code works. Otherwise, you'll
have to do some serious study on how Java I/O works.

Many, many years ago, when I was in Java short pants, I wrote this note
to myself:

http://www.javahotchocolate.com/topics/pfileio.html

Here are some good (probably better) links to read on this topic:

http://stackoverflow.com/questions/437382/how-do-relative-file-paths-work-in-eclipse

http://docs.oracle.com/javase/tutorial/essential/io/path.html

http://www.mkyong.com/java/how-to-construct-a-file-path-in-java/

http://www.avajava.com/tutorials/lessons/whats-the-difference-between-a-files-path-absolute-path-and-canonical-path.html

I hope some of this helps.

Best of luck.
Re: FileNotFound [message #1010315 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010319 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010323 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010327 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010331 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010335 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010339 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010343 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010347 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010352 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010356 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010361 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010365 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010369 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010373 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010377 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010383 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010387 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010391 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010395 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010400 is a reply to message #1010248] Sun, 17 February 2013 05:28 Go to previous messageGo to next message
Sally Budack is currently offline Sally BudackFriend
Messages: 22
Registered: February 2013
Junior Member
Thanks for the input. The error of my ways was importing the text file from the file menu rather than from the package explorer. Simple but huge difference.
Re: FileNotFound [message #1010502 is a reply to message #1010315] Sun, 17 February 2013 13:45 Go to previous message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
On 02/16/2013 11:28 PM, Sally Budack wrote:
> Thanks for the input. The error of my ways was importing the text file
> from the file menu rather than from the package explorer. Simple but
> huge difference.
No, that has nothing to do with it. As Russell said, this involves path
resolution at runtime. You need to spend some time understanding things
like current/running directory. Programs run in a specific directory.
That has to be consistent with the relative paths to files that your
program looks for.
Previous Topic:error: target CPU does not support ARM mode
Next Topic:How to take ALL of my Eclipse preferences with me?
Goto Forum:
  


Current Time: Fri Apr 19 20:17:19 GMT 2024

Powered by FUDForum. Page generated in 0.10087 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top