在 java.io.FileNotFoundException 中查找文件位置
我有这个 Java 应用程序,并且正在使用外部 Jar,其中一个函数抛出 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您在调试器中运行应用程序,大多数调试器都允许您在引发异常时中断。然后,您可以检查应用程序的本地状态以确定相关路径。
您还应该将此作为增强请求报告给原始库作者(以在引发的异常中包含文件名)。
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).
你不需要包含该方法的Java类的
.class
文件吗?如果是,反编译它以查看源代码。这就是一个这样的反编译器另外,尝试一下查找可能具有路径信息的任何配置文件(如属性文件)。
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 decompilerAlso, try to look for any config file like a property file that may have the path information.
System.getProperty("user.dir")
and do some hit-trial by placing the file there.如果异常堆栈没有提示您在哪里查找文件,并将其放置在常见位置(例如
不起作用,我想您可以反编译该 jar 并查看它在哪里寻找文件
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.
does not work, I guess you can decompile the jar and see where it is looking for the file
好吧,我怀疑它是硬编码的,所以这可能不会告诉你它到底在哪里......但你可能想使用 JAD。这可能会提示您它正在寻找的位置。
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.