6

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.

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?

Jason S
  • 184,598
  • 164
  • 608
  • 970
  • For what it's worth, this is a pet peeve of mine w/r/t editors. They typically only show you the filename and offer you no way of showing the full path of the file in question, assuming that since you're the one who loaded the file into the editor, that you know which file it is, never mind the fact that there could be two files in different directories with the same filename. (One of the versions of Excel "solved" this by not allowing you to open two files with the same name even if they were from different directories.) – Jason S Apr 13 '11 at 20:48
  • Eclipse now shows the full path to the file in the window titlebar. – Robin Green Feb 15 '12 at 18:46

2 Answers2

8

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.

ILMTitan
  • 10,751
  • 3
  • 30
  • 46
5

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.

Chin Huang
  • 12,912
  • 4
  • 46
  • 47
  • ...but how do I know which JAR file it is? – Jason S Apr 13 '11 at 20:53
  • (e.g. if I have two `flaky.jar` files in different directories) – Jason S Apr 13 '11 at 20:53
  • Are you downloading these jar files from somewhere or these are your jar files? Are these jar files in your build path? – yogsma Apr 13 '11 at 20:58
  • They're my jar files. But I'm not sure if they're from the build path or the class path, or whether Eclipse is caching old .jar files or what. – Jason S Apr 13 '11 at 21:03
  • Ok, this is a crude solution I can suggest >> Since these are your jar files, search their location on your machine, move one jar file from its location to some other temporary directory. Try debugging again, since you have moved one jar file, you might get error if the source code is from the moved jar file else it will be from other jar file. Also possibly from their last date of edit you can get which jar file is recent one. – yogsma Apr 13 '11 at 21:07
  • Same problem, different libraries http://stackoverflow.com/questions/5616233/how-do-i-install-jung2-on-eclipse/5618076#5618076 – eee Apr 14 '11 at 02:02