Classified
Classified

Reputation: 6050

In Eclipse, how to attach different source files when debugging

While debugging our web app, we needed to trace thru the code, including 3rd party open source software.

When looking at this problem with several people on my laptop, someone quickly downloaded the latest source jar file and pointed our project to that jar file. However, since it's not the same version, the lines of code don't match so when debugging, it can point to blank lines.

Afterwards, I found the correct git branch, and downloaded the correct version of code, or at least it's closer to the code we're using than the code someone else downloaded. However, it seems like Eclipse is still using the old code. In Eclipse, I went into Projects->Properties->Java Build Path->Libraries and deleted the jar file that I think contains the code but it still seems to be using the old code.

When I continue debugging after deleting this file, it doesn't give me the choice to Attach Source. How do I make Eclipse allow me to use another source file when tracing thru code when debugging?

If deleting the jar file should have fixed this problem, then I probably deleted the wrong jar file and will delete this question since it's user error.

Upvotes: 0

Views: 1688

Answers (2)

Christian Frommeyer
Christian Frommeyer

Reputation: 1420

If you are using maven you can instruct maven to automatically download the source jars. This should usually be the right version.

Upvotes: 0

Kon
Kon

Reputation: 10810

In the Debug view, select the Debug tab. Right click your debug instance and choose "Edit source lookup..."

See below:

enter image description here

Be sure to run a Project Clean after changing the source lookup. I have run into many inconsistencies in various versions of Eclipse with this feature.

Upvotes: 1

Related Questions