In Maven: how to attach sources to tools.jar
Asked Answered
M

1

8

I have to use libraries in tools.jar and have therefor added this dependency:

<dependency>
    <groupId>com.sun</groupId>
    <artifactId>tools</artifactId>
    <version>1.6.0</version>
    <scope>system</scope>
    <systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>

Now I would like to attach the sources in Eclipse, so I see what I develop against. I guess nothing will be available in the standard maven repositories (I can't even find anything in download.java.net/com/sun).

I know there is a source archive available, but it contains everything and I would at least need to know what parts of it need to go in the source jar.

Has someone done this? Is there a tools-sources.jar available somewhere? Or can you tell me what parts of the jdk sources I need?

Monkhmer answered 7/9, 2010 at 7:39 Comment(2)
Good question. Didn't realize this could be complicated.Seraphim
Seems like I am a specialist for asking questions no one can answer :-)Monkhmer
M
7

Here's what I did. I downloaded the source archive from openjdk, extracted it and manually linked the jar source to

External Folder -> [unpacked archive basedir]/langtools/src/share/classes

This is not a maven solution, it's eclipse only, but it works.

Monkhmer answered 7/9, 2010 at 14:18 Comment(1)
This works for IntelliJ too! In a class in tools.jar (FieldDoc), clicked on the Attach Sources and browsed to openjdk-6-src-b27-26_oct_2012.tar\langtools\src\share\classes.Magistracy

© 2022 - 2024 — McMap. All rights reserved.