Eclipse:显示类文件的代码源?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5655362/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse: displaying code source for class file?
提问by Jason S
I'm running Eclipse 3.5.2 and am debugging a class which calls a method -- let's call it flaky()
-- in one of my other .jar files. When I step into flaky
(), it shows the source code in a tab in the debugger, with the filename as Flaky.class.
我正在运行 Eclipse 3.5.2 并且正在调试一个类,该类flaky()
在我的其他 .jar 文件之一中调用一个方法——让我们调用它。当我进入flaky
() 时,它会在调试器的选项卡中显示源代码,文件名为 Flaky.class。
The problem is, the code I see looks old and out of date, so I'm wondering which file I'm looking at.
问题是,我看到的代码看起来很旧而且过时了,所以我想知道我在看哪个文件。
Is there any way to find out the path of the file Eclipse is displaying?
有什么办法可以找出 Eclipse 显示的文件的路径吗?
回答by ILMTitan
Go to the Package Explorer view with the file open in the current editor. Click the "Link with Editor" toggle (the two arrows). This should jump you to the class file you are viewing, which should be in the jar you are using. If the jar is in a library, you should see the path to the jar in the package explorer. If not you can see the path to it in the preferences. From there you can also use Chin Huang's answer to find where the given source file is.
转到在当前编辑器中打开文件的 Package Explorer 视图。单击“与编辑器链接”切换按钮(两个箭头)。这应该会跳转到您正在查看的类文件,它应该在您正在使用的 jar 中。如果 jar 在库中,您应该会在包资源管理器中看到 jar 的路径。如果没有,您可以在首选项中看到它的路径。从那里您还可以使用 Chin Huang 的答案来查找给定源文件的位置。
回答by Chin Huang
View the Properties for the JAR file. Under Java Source Attachment, you will see where Eclipse gets the source code for classes in the JAR file.
查看 JAR 文件的属性。在Java Source Attachment 下,您将看到 Eclipse 从何处获取 JAR 文件中类的源代码。