ranzy
ranzy

Reputation: 179

find file location in java.io.FileNotFoundException

I have this Java application and I'm using an external Jar and one of the functions is throwing a java.io.FileNotFoundException. I have the file that it's looking for but I have no idea where I'm supposed to put it. Is there any program I can use that can give me the location of the path that it's trying to look at? Thanks.

Upvotes: 1

Views: 921

Answers (4)

Piyush Mattoo
Piyush Mattoo

Reputation: 16095

  • Don't you have to the .class file of the Java class containing that method.If yes, decompile it to view the source code. This is one such decompiler

  • Also, try to look for any config file like a property file that may have the path information.

  • You can find the current working directory from System.getProperty("user.dir") and do some hit-trial by placing the file there.

Upvotes: 0

jtahlborn
jtahlborn

Reputation: 53674

if you run the application in a debugger, most debuggers allow you to break when an exception is thrown. you could then inspect the local state of the application to determine the relevant path.

you should also probably report this as an enhncement request to the original library author (to include the file name in the thrown exception).

Upvotes: 2

smp7d
smp7d

Reputation: 5032

Well, I doubt it is hardcoded so this will probably not show you exactly where it is looking...but you may want to decompile the class using JAD. This may clue you in on where it is looking.

Upvotes: 0

Cratylus
Cratylus

Reputation: 54074

If the exception stack does not give you a hint on where it is looking for the file, and placing it in common places e.g.

  • in user directory
  • home directory
  • current directory etc

does not work, I guess you can decompile the jar and see where it is looking for the file

Upvotes: 0

Related Questions