开发者

find file location in java.io.FileNotFoundException

开发者 https://www.devze.com 2023-04-13 05:59 出处:网络
I have this Ja开发者_高级运维va 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 id

I have this Ja开发者_高级运维va 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.


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).


  • 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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消