Tearing hair out over attach sources

I have tried on several occasions in the past to get Java source files successfully attached to my project, and each time I have given up in despair.  This time, however, I really really need to step into JTable, so I've come here in the desperate hope that some kind soul can help me achieve attached-sources nirvana :)

I go into Project Structure, I go to the Libraries (not Global Libraries) tab and I click on Attach Sources.  I navigate to the Java class files, which are organised as-received from Sun in the source distribution:

I choose the "classes" folder as shown above, and then click the OK button.  Sometimes IntelliJ spends quite some time rebuilding its indices, which gets me all excited and thinking that this time, this time, really it is going to work.

But no.  Every time, when I command-click (I'm on the Mac) on a Java class name in my source (say, JTable), I am taken to the precompiled stub version and not to the source.  Aaaaarrrrrgggghhhhh!!!!!!!!!!!  ?:|

Please can someone help me get these source files available to my IDE?

IntelliJ 9.0.2, if it makes any difference.  (And yes, I know there's a new version out, but I am the opposite of an early adopter.  "If it ain't broke, don't fix it."  I'll update if someone tells me that the above was a known bug in that version and that it has definitely been fixed in the new version ;) )

Grateful TIA!

Comment actions Permalink

Ski addict,

the Sun/ Oracle JDK is not compiled with debug line info for many classes; for java swing I know this is definitely the case.  It's nothing to do with IntelliJ.

Good luck

Comment actions Permalink

Thanks, but I'm confused.  If there is no debug line info then how do exceptions report line numbers?  Also I have heard that this is possible in other IDEs, so ?????

Comment actions Permalink

When you define a new JDK, IDEA will automatically recognize the "src.zip" archive (if present), and add it to the source path of the new JDK.
There is no need to manually configure anything. (see attached screenshot for an example from Windows)

Try to delete your JDK definition, and create a new one from scratch.



Comment actions Permalink

Thank you so much!  I really cannot thank you enough for solving this for me.

Note for future readers of this thread: you don't necessarily have to have the sources in a zip file, or recreate your JDK.  I just went to the Sourcepath tab, pressed on Add, navigated to the folder where my sources are (see screenshot in original post) -- and IntelliJ did the rest.


Thanks again :)


Please sign in to leave a comment.