Attaching jdk src to Intellij

Answered

I would like to attach the jdk src.zip to a module (it would actually be nicer to do this at a global level for IDEA) and I am not sure if I am doing it right. I have unzipped the src into a folder and added it as an additional source root. This works great for browsing jdk sources but whenever I try to run my application, Intellij has to parse ALL of the JDK sources again. This takes about 30 seconds.

Please tell me there is a better way to do this.

Thanks,

Tony

0
7 comments
Avatar
Permanently deleted user

Ok, I figured it out. In the Project view under libraries it will show the JDK. I click on jump to source and at the configuration screen for the JDK's there is an option to change the source path. Whew.

0

What do you really want to achieve?
If you set up a JDK the regular way (project settings, JDK), IDEA automatically attaches the zipped source.
You can browse and navigate the sources that way just fine.

-3

Hello Tony,

I would like to attach the jdk src.zip to a module (it would actually
be nicer to do this at a global level for IDEA) and I am not sure if I
am doing it right. I have unzipped the src into a folder and added it
as an additional source root. This works great for browsing jdk
sources but whenever I try to run my application, Intellij has to
parse ALL of the JDK sources again. This takes about 30 seconds.


Go to Project Structure dialog, select the "JDKs" node, select your JDK,
select the "Sourcepath" tab, press the "Add" button and select src.zip (it's
actually added there by default, so I'm not sure why it wasn't picked up
automatically for you). You don't need to unpack the archive or add it as
a source root.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


2

I found Sourcepath tab in File -> Project Structure -> SDKs.

0

but how do you change the search order of the “sourcepath”, using ‘+’ appends it to the list, is there a way to prepend such that it will override, for example if you were debugging a patch module that overrode JDK classes …

0

Hi @Larry Cable, it looks like there is no way to prioritize a list of sources, and I couldn't find any similar feature requests  in our bug tracker

Here’s a workaround I came up with for now: if you have two JDK versions—one with a patch and another with the default sources—you can create separate copies of each JDK on your machine and add them individually via File | Project Structure | SDKs | Add new SDK, assigning the appropriate source set to each. Then, switch between them as needed via File | Project Structure | Project—use the patched version when debugging, or switch back to the default as necessary.

IntelliJ IDEA should pick a JDK defined via File | Project Structure | Project on a runtime

Does this help?

0

Egor Klepikov thanks in the end I simply built a Jdk with the “patched” classes included, its not ideal since it obviates

--patch-module but it works, thanks!

0

Please sign in to leave a comment.