This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IntelliJ IDEA Debugging Question

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on an application and using a 3rd party library. I'm running into issues and I can't tell if it is my code or the 3rd party's code. I have their source code but since I am using their JAR file(s) in my project when I debug I'm not able to see the actual method implementations.

Is there a way to attach source code to a project from an external location just for debugging? So that when I step through I can actually step their their source code as well?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, with a bit of help I managed to figure this out. You go to Project Settings and in the Libraries/Global Libraries section there is an Attach Sources button. Once the sources are attached you set breakpoints on the code by using the project view's tree. Just find the Libraries node, usually right under your module node. Expand it and find the library and you can double click the classes. Since the source code is no linked you get a view of the source code and are able to set breakpoints.
 
Peter Petrov
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your approach worked for me, thanks for that.

I found your post after doing a google search
for "debug third-party code with Intellij IDEA".

Which version of IntelliJ IDEA are you using?
I am currently working by using Intellij IDEA 7.0.5.

But I was expecting to get that behaviour (which you describe) by
adding the third party sources to the Application Server definition:
-> Click "Run"
-> Click "Edit Configurations"
-> Choose some Tomcat/JBoss server configuration which you already defined in IntelliJ IDEA
-> From the right container, from the server tab choose "Configure"
-> Click "Attach Sources"

So my question is: if my expectation is wrong, what is
the meaning of "Attach Sources" there (where I described) ?

Thanks in advance.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic