views:

58

answers:

4

Hi all,

First off I'm not a Java expert by any stretch, nor am I a regular Eclipse user. Due to personal circumstances of a member of our team I have had to step into the breach and fix some bugs in two java applications currently under development.

We have a core application (CORE) and an API which includes a reference to that CORE. What I need to do is debug the API but step into the CORE code. I have all the source code for both projects loaded into the IDE but I can't hit breakpoints in the CORE. I'm assuming it is using the jar version of the CORE included in the API as opposed to the code in the CORE.

I hope that makes sense.

Cheers

+3  A: 

Define a breakpoint in the API by clicking on the left side column of the editor. Then, try to step into a function of CORE. Eclipse will complain that it cannot find the sources to debug. However, a button will appear that will let you define where to find these sources: either in a jar file or in an external directory.

If you were to include the sources of CORE along with the classes of CORE, normally eclipse will find it automatically as well.

Cheers

YuppieNetworking
OK thanks that's useful in that that is exactly what I expected to happen. Maybe I'm on the right track but something is not quite right.
Simon Rigby
A: 

What you need to do is remote debugging. Here is one (of several) articles covering that topic and showing how to set up a remote debugging session. (near to the end of the text)

Basically you start the application with some extra parameters while on eclipse you have a projects that contains the source code. Then you start a remote debugging session and can set breakpoint, inspect variables, etc. on the remote JVM.

Andreas_D
I assumed, that CORE is not started from eclipse but is running elsewhere...
Andreas_D
API includes a lib reference to CORE.jar. The API calls into the CORE for various functionality. I am able to set a breakpoint but its not hit.
Simon Rigby
sorry i mean the breakpoint is not hit in Core .. API breakpoints are. main is in API (ie API starts the action)
Simon Rigby
are you setting the breakpoint in the source code of the Core *project*?
matt b
A: 

You probably have the CORE java classes which are compiled by Eclipse to byte code and present in the IDE. THat means that the code invoked by the API is most likely NOT the code you think as it is probably present in jar files next to the API.

What you need to to is to attach the sources to the jar files instead in their properties. Either zip them up and attach that zipfile or attach the folder where the "com"/"org" etc package names start.

Thorbjørn Ravn Andersen
Ok this is the Source Code Attachment property?
Simon Rigby
+2  A: 

I have all the source code for both projects loaded into the IDE but I can't hit breakpoints in the CORE. I'm assuming it is using the jar version of the CORE included in the API as opposed to the code in the CORE.

Change the build path of the second project so that instead of referring to a packaged JAR of the first project, it refers to the project itself.

In the properties of the second project, go to Java Build Path, remove the JAR from the Libraries tab, and add the first project under the Projects tab.

matt b
Thanks very much that is exactly what I was after. Am now able to step through both projects hitting breakpoints as appropriate.
Simon Rigby