• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FileNotFoundException in wired situation

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i had build an application in java which runs properly in win7 but throws n FileNotFoundException in winxp , can any one explain me why ?
 
Henry Wong
author
Marshal
Pie
Posts: 21423
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naved momin wrote:i had build an application in java which runs properly in win7 but throws n FileNotFoundException in winxp , can any one explain me why ?


Well, the most likely reason is that the file exists on win 7, but either doesn't exist, or isn't accessible on XP.

Henry
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
naved momin wrote:i had build an application in java which runs properly in win7 but throws n FileNotFoundException in winxp , can any one explain me why ?


Well, the most likely reason is that the file exists on win 7, but either doesn't exist, or isn't accessible on XP.

Henry

thanks for reply henry but there is a strong reason behind asking this question
I am chosing the file using JFileChooser so there is no option that the file i have choice doesn't reside on the pc.
now what you have to say ?
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to say there is a bug in your code.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49813
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naved momin wrote: . . . now what you have to say ?
Careful. Some people might think such talk rude.

The file not found Exception (FNF) can be thrown in several circumstances, as you can find from its documentation. There is an example on that link of when a file may exist, but you still suffer an FNF. It is possible that you are actually trying to open a file which as a system file is inaccessible to you.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:I'm going to say there is a bug in your code.

OK if I agree than, my question is why it works on win7 ? it should also not work in win7
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
naved momin wrote: . . . now what you have to say ?
Careful. Some people might think such talk rude.

The file not found Exception (FNF) can be thrown in several circumstances, as you can find from its documentation. There is an example on that link of when a file may exist, but you still suffer an FNF. It is possible that you are actually trying to open a file which as a system file is inaccessible to you.

OK , I will give another try on some other pc and then lets see what happens next ... will continue
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why should it? There's no guarantee that two Windows computers are going to have exactly the same set of files. In fact it's a certainty that they won't. So it's perfectly possible that you can access file X on Computer A (because it exists there) but not on Computer B (because it doesn't exist there).

So come on. You're claiming that your code doesn't have a bug, but that the Java JRE has a bug which has gone unnoticed by millions of programmers until you found it. That's a waste of time for all concerned. The best bet is that your code has a bug, and you should proceed on that basis.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Why should it? There's no guarantee that two Windows computers are going to have exactly the same set of files. In fact it's a certainty that they won't. So it's perfectly possible that you can access file X on Computer A (because it exists there) but not on Computer B (because it doesn't exist there).

So come on. You're claiming that your code doesn't have a bug, but that the Java JRE has a bug which has gone unnoticed by millions of programmers until you found it. That's a waste of time for all concerned. The best bet is that your code has a bug, and you should proceed on that basis.

oohh! I m not telling JRE has a bug , I know there are more intelligent people then me including you all, but I need to know whether any one has faced this same problem and if yes he can help me sorting out this one ....
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course. Everybody has had the situation where they couldn't find a file because they did something wrong. Imagining that nobody else has ever had such a problem is a rather strange way of starting to investigate.

I'm sure you already know about debugging. In this case display the full path of the file which doesn't exist, and look at it.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The java.io.File class has a number of useful methods that you should call and then print out the results, so you can learn about the file in question. For instance, getFullPath() (or something like that), exists(), isFile(), icanRead(), etc.

Look at File's methods and think about all the things you might want to learn about that file that might help you build a more complete picture of what's going on.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic