Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » "The system cannot find the file specified"
"The system cannot find the file specified" [message #175807] Sun, 29 August 2004 15:40 Go to next message
Eclipse UserFriend
Originally posted by: peng.cs.unt.edu

I have a project 'Test' with 2 files:
1. E:\workspace\test\src\Test.java (code listing see below)
2. E:\workspace\test\src\abc.txt

When I use "Run As Java Application", I got an error message:
"java.io.FileNotFoundException: abc.txt
(The system cannot find the file specified)"

If I move abc.txt to E:\workspace\test\abc.txt, it will succeed.

Could you tell me how to set up Eclipse so that I don't need to move
my resource files (keep them in src folder)?

Thanks.

>>>>>>Here is my Test.java:
import java.io.*;
public class Test {
public static void main(String[] args) {
try {
BufferedReader reader = new BufferedReader(new
FileReader("abc.txt"));
System.out.println(reader.readLine());
} catch (IOException e) {
System.out.println(e);
}
}
}
Re: "The system cannot find the file specified" [message #175898 is a reply to message #175807] Mon, 30 August 2004 10:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.NO.SPAM.us.ibm.com

Do you have src/ marked as a source directory in your java build path?


--
Thanks, Rich Kulp

Re: "The system cannot find the file specified" [message #175904 is a reply to message #175807] Mon, 30 August 2004 11:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eostroukhov.hotmail.com

My guess is that it uses project folder as a working folder. Open properties
of the launch configuration and on the arguments tab set working directory
to the src folder.

Eugene

"Sean" <peng@cs.unt.edu> wrote in message news:cgtbfu$eol$1@eclipse.org...
> I have a project 'Test' with 2 files:
> 1. E:\workspace\test\src\Test.java (code listing see below)
> 2. E:\workspace\test\src\abc.txt
>
> When I use "Run As Java Application", I got an error message:
> "java.io.FileNotFoundException: abc.txt
> (The system cannot find the file specified)"
>
> If I move abc.txt to E:\workspace\test\abc.txt, it will succeed.
>
> Could you tell me how to set up Eclipse so that I don't need to move
> my resource files (keep them in src folder)?
>
> Thanks.
>
> >>>>>>Here is my Test.java:
> import java.io.*;
> public class Test {
> public static void main(String[] args) {
> try {
> BufferedReader reader = new BufferedReader(new
> FileReader("abc.txt"));
> System.out.println(reader.readLine());
> } catch (IOException e) {
> System.out.println(e);
> }
> }
> }
>
>
Re: "The system cannot find the file specified" [message #175964 is a reply to message #175904] Mon, 30 August 2004 17:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: peng.cs.unt.edu

Eugene Ostroukhov and Rich Kulp:

Thank you both for the kindly help.

In this case, Eugene' instructions solve my problem.
Thanks a lot.

I did mark src/ as a source directory in my java build path before.

My Preferences>Java>Build Path has
Source folder name: src
Output folder name: bin

When "Create a Java project", I set
'Project layout' to 'Create separate source and output folders' and
'Source folders on build path:' to test/src and
'Default output folder' to test/bin.

However, I did not set up working directory to the src folder before.
I thought Eclipse could infer that info automatically.

By the way, seting up working directory to the bin/ folder also worked
since Eclipse copied my resource files to the bin/ folder.

As a newbie I spent serveral hours on this issue.
Many thanks to you two.

Sean

>>>>>>>>>>>>>>>>>
Eugene Ostroukhov wrote:

> My guess is that it uses project folder as a working folder. Open properties
> of the launch configuration and on the arguments tab set working directory
> to the src folder.

> Eugene

> "Sean" <peng@cs.unt.edu> wrote in message news:cgtbfu$eol$1@eclipse.org...
> > I have a project 'Test' with 2 files:
> > 1. E:workspacetestsrcTest.java (code listing see below)
> > 2. E:workspacetestsrcabc.txt
> >
> > When I use "Run As Java Application", I got an error message:
> > "java.io.FileNotFoundException: abc.txt
> > (The system cannot find the file specified)"
> >
> > If I move abc.txt to E:workspacetestabc.txt, it will succeed.
> >
> > Could you tell me how to set up Eclipse so that I don't need to move
> > my resource files (keep them in src folder)?
> >
> > Thanks.
> >
> > >>>>>>Here is my Test.java:
> > import java.io.*;
> > public class Test {
> > public static void main(String[] args) {
> > try {
> > BufferedReader reader = new BufferedReader(new
> > FileReader("abc.txt"));
> > System.out.println(reader.readLine());
> > } catch (IOException e) {
> > System.out.println(e);
> > }
> > }
> > }
> >
> >
Re: "The system cannot find the file specified" [message #175972 is a reply to message #175964] Mon, 30 August 2004 18:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.NO.SPAM.us.ibm.com

Ah, right. I was thinking it was using the classloader to find the file,
but I forgot File(afilename) uses the working directory, which is
entirely different.

If it was using the classloader, then it needs to be in a source
directory, which then copies it to the bin directory so that the
classloader can find it.


--
Thanks, Rich Kulp

Re: "The system cannot find the file specified" [message #176123 is a reply to message #175972] Tue, 31 August 2004 10:17 Go to previous message
Eclipse UserFriend
Originally posted by: peng.cs.unt.edu

Rich Kulp:

Thanks.

I have other projects that I have not moved to Eclipse.
They use classloader. You advices will certainly help.

Sean.
Previous Topic:[Bug] "Sort members" ignore dependancies between static variables.
Next Topic:New: how to set up a project with existing files
Goto Forum:
  


Current Time: Fri May 09 04:46:58 EDT 2025

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

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

Back to the top