Open source libraries are very popular in Java world. Nowadays Java/J2EE/Android developers often work with Java-based projects which using a lot of open source Java libraries. One issue with using open source Java libraries is how to find documentation/source code for these open source libraries fast and easily? It is tedious and time consuming to search for the source code, download and attach source code packages to the libraries. If your project has 40 libraries, how long will it take to find source code for all libraries? The solution is to use this Eclipse plugin to do the task for you with only one mouse click. This Eclipse plugin will help to find source code for open source Java libraries automatically from Internet. Just right click on a Java library, choose the menu item "Attach Java Source" and wait. The source code for the library will be found and attached to the Java library in several seconds.
Note: This project is mostly useful when you don't have Maven/Gradle to mange project dependencies. If your project uses Maven/Gradle, Eclipse should support downloading source code and this plugin is not really needed.
Install plugin:
- Use Update site URL: https://dl.bintray.com/tha/eclipserepo/
- Or download offline: download plugin from https://dl.bintray.com/tha/eclipserepo/plugins/org.freejava.javasourceat... and save it to eclipse/dropins/ folder
Bug Report: https://github.com/tha2015/free-plugins/issues
Note for Android developers: - When programming Android projects using Google ADT plugin, the jar files inside libs folder will be added as libraries automatically but Eclipse will not allow change source code path for these libraries. This plugin can attach source code for Android libraries and will help Android developers in coding / debugging.
Usage: Right click on a Java library of a Java-based project and choose the menu item "Attach Java Source" and wait for the source code to be downloaded/attached to the library automatically (you will see a background job is running on Eclipse status bar).
Features:
- Find source code for Java libraries using all popular Java repositories on Internet (Like Maven Central repository, Nexus-based repositories, Eclipse P2 repositories, ...)
- Eclipse plugin developers can use this plugin to find source code for Eclipse plugins using Eclipse P2 repository.
- (NEW) Support attaching source code for rt.jar (i.e. Oracle JRE 7 or JRE 8). Please provide feedback for this feature.
- The plugin also uses a special cloud-based search service designed for the plugin. This search service contains information about all Apache Java projects. This means source code for any Apache Java-based library will be found.
- If source code for a Java library cannot be found, the user can help the community by providing the URL to the source code archive file (in Zip or Jar file format) or SCM URL (see below note) and the source code will be found next time! You are helping youself and others when providing information about source code for a library!
Compatibility: Tested with Eclipse 3.5 to 3.8 (but should also work with 4.x).
Requirements: - JDK 6+ - Eclipse 3.5+ - An Internet connection (to search and download source code)
SCM URL format (used when you provide source code location from SCM systems): The SCM URL will follow the format supported at http://maven.apache.org/scm/scm-url-format.html with option fragment to indicate version as below. Various SCM types are supported (Git SVN CVS Mercurial ...).
SCM_URL [#(tag|branch|revision)=xxx]
Examples:
scm:svn:http://svn.apache.org/svn/root/module/trunk
scm:svn:http://svn.apache.org/svn/root/module/branches/bbb
scm:git:https://github.com/path_to_repository.git
scm:svn:http://svn.apache.org/svn/root/module#revision=rrrr
scm:svn:http://svn.apache.org/svn/root/module#tag=tttt
scm:git:https://github.com/path_to_repository.git#branch=bbb
scm:git:https://github.com/path_to_repository.git#tag=tttt
scm:git:https://github.com/path_to_repository.git#commitId=xxxx
You might also like the plugins:
- Java Examples Search to find example code from Eclipse.
- Java Dependency Viewer to view your class dependencies and package dependencies visually.
Reviews Sign in to post reviews
Getting error as No repository found
Submitted by Zainab Ahmedi on Thu, 2023-01-12 11:56
Getting below error when trying to install this plugin :No repository found at h ttps://dl.bintray.com/tha/eclipserepo/.
Not able to add plugin
Submitted by Katta Nagarjuna on Mon, 2022-05-02 09:10
When I try to add a plugin this is not installing. Getting 502 error always.
not compatible with eclipse 2019
Submitted by Oliver Joychan on Thu, 2019-11-28 20:56
not compatible with eclipse 2019 version any more
Download path configuration and existing source check
Submitted by Dead Or on Fri, 2016-07-01 02:13
Please, add simple configuration of sources download path. Alternative offline source paths config would be nice too (or check for existing sources in ".sourceattacher" folder before downloading at least)
Thank you!
Re: Download path configuration and existing source check
Submitted by Mitch Lazzlo on Tue, 2017-09-05 03:47
+1
Added support for using cached files
Submitted by Missing name Mising name on Mon, 2016-07-18 09:07
The latest version 1.2.8 will check for local cached source files before trying to download from Internet.
Note: You will find new *.meta files in the ".sourceattacher" folder containing meta data to support this feature.
Adding preferences to configure plugin's cache folder would take time and cannot be implemented at the moment.
Thanks for support.
rt.jar source downloading doesn't seem to work for JDK
Submitted by Tom Rodriguez on Tue, 2016-05-17 16:43
When I select Attach Java Source for rt.jar in a JDK the plugin doesn't appear to do anything. If I select another jar from that JDK like zipfs.jar I can see it go to work downloading the source in the error log. I can then use that same zip file for the rt.jar sources. I would be nice if it worked correctly for rt.jar. Nice plugin otherwise though!
Maybe the rt.jar already has
Submitted by Missing name Mising name on Wed, 2016-05-18 15:49
Maybe the rt.jar already has some source code (i.e. src.zip) attached (so the plugin didn't do anything) or the plugin is still in progress to download the source code from Internet (you would have to wait until the background job "Attaching source to library..." disappears from Eclipse status bar). I've just removed src.zip from my rt.jar (jdk version 1.8.0_66) and tried the plugin and it did work for me.
This plugin is not available at the specified URL
Submitted by Kundan Verna on Thu, 2016-05-12 19:08
I tried to install this plugin from all the URL mentioned but no where it is available.
Please provide the correct URL for installing this useful plugin.
URL has been updated
Submitted by Missing name Mising name on Fri, 2016-05-13 13:16
Thanks for the info. I didn't know that that hosting site was retired. I've just uploaded files to Bintray and updated the URL. Please try again.
Really useful
Submitted by Torkild Resheim on Wed, 2016-03-16 09:47
I just discovered this plug-in in need for source code on a project where I don't control the target platform. This is really a life saver. However I wonder whether or not it is actually using the "Eclipse-SourceReferences:" attribute in MANIFEST.MF when it comes to Eclipse plug-ins. It does not appear so, but it should.
Thanks for the idea.
Submitted by Missing name Mising name on Wed, 2016-05-18 15:53
Thanks for the idea. Currently it doesn't check for Eclipse-SourceReferences in MANIFEST.MF, I will think about implementing it when I have some time.
Implemented Eclipse-SourceReferences support in 1.2.7
Submitted by Missing name Mising name on Mon, 2016-06-13 02:11
Implemented Eclipse-SourceReferences support in 1.2.7
Where to report bugs?
Submitted by Missing name Mising name on Wed, 2015-02-25 13:47
Where can I report bugs? There is no such feature here, is it?
The Source Attacher plugin doesn't work for me, but keeps hanging. The progress bar stays active forever.
I debugged the problem to the "WebBasedArtifactorySourceCodeFinder....js" file: The assignment of values to the input forms doesn't work.
Since the assignment doesn't work, the script keeps looping forever in the "sleep while loop".
I adapted the script as the following:
ie.document.getElementsByName('groupIdField').item(0).value = groupId
ie.document.getElementsByName('artifactIdField').item(0).value = artifactId
ie.document.getElementsByName('versionField').item(0).value = version
ie.document.getElementsByName('classifierField').item(0).value = 'sources'
It would be great if the JavaScript could be adapted!
Thank you a lot !
Submitted by Missing name Mising name on Fri, 2015-04-10 10:22
I have updated the JS code as you suggested and verified that it is working good now. Thank you for contribution. NOTE: I used the same plugin version so you will see the changes when you installing in a new Eclipse
In addition
Submitted by Missing name Mising name on Thu, 2015-02-26 11:00
I have to add, that I tried to download sources for my commons-logging-1.2.jar.
The website in question was: repo.spring.io/webapp/gavcsearch.html?0
Even when I fixed the script and executed it, I saw that the search yields to two results: sources.jar and test-sources.jar.
And I saw, that the latter one is chosen and returned by the script. This doesn't seem to be correct?!
This issue is also fixed
Submitted by Missing name Mising name on Fri, 2015-04-10 10:31
Thank you for finding this issue. It is also fixed.
Change saved source folder
Submitted by Gonçalo Cardoso on Thu, 2015-02-19 07:44
Is there any way to change where the sources are saved?
By default it's saved on C:\Users\xxxxxx\.sourceattacher but I wanted to save them inside the project so that I could share them with the rest of my team.
Does not work for me
Submitted by Malte Mahlzahn on Wed, 2014-12-03 11:06
I tried attaching the sources of SWT and the JDT but neither of them works.
I am using Luna on Linux.
Thank you for the info. This issue is fixed
Submitted by Missing name Mising name on Fri, 2015-04-10 23:11
Some of the sites I used for search Eclipse plugin source code were not working. I have fixed by using some new sites. I tested with latest Eclipse (Luna) and verified that it can find the source code for plugins correctly. But one issue is the attached source jar will be lost the next time Eclipse is started so you will have to re-attach source again. Sorry about this issue but I don't see it will be fixed soon.
Worked very well for me!
Submitted by David Clemens on Fri, 2014-04-11 17:54
I just installed this plugin in a Kepler Eclipse and asked it to attach the source for one of the core Eclipse plugins so that I could see how it worked. Plugin sources no longer seem to be included in Eclipse releases, and I had been very frustrated trying to find them. But this Attacher found them automatically, downloaded and attached them in a few minutes.
Worked like a charm. I can't speak for other Open Source jars, but for Eclipse plugin sources, it was exactly what I needed.
It didnt work
Submitted by Johan Kempe on Tue, 2014-01-14 09:50
It didnt work for me when I tried to attach gson-2.2.4-sources.jar to gson-2.2.4.jar
No error message, nothing happened.
It works
Submitted by Missing name Mising name on Thu, 2014-03-27 21:23
I tested with Eclipse 3.8 and your specified jar file at http://repo1.maven.org/maven2/com/google/code/gson/gson/2.2.4/ and it worked correctly for me.
Option not enabled in sub folder Web-inf/lib or Navigator view
Submitted by dabraham_1234@hotmail.com on Wed, 2013-10-16 05:00
Thank you for this lovely tool! However, the option to 'Attach Java source' is grayed out for libraries that are in a different folder like say src/webroot/web-inf/lib. Also this option is grayed out when I try accessing it from the Navigator view, it's available in the Project Explorer view though. It would be nice if it can be activated for arbitrary libraries and in Navigator.
You must have the jar in the Build path of project first
Submitted by Missing name Mising name on Thu, 2014-03-27 21:22
You must have the jar in the Build path of project first, the plugin cannot attach source code for any jar files not in project's Build Path.
This plugin can attach source code for Android libraries - how ?
Submitted by Palmer Eldritch on Sat, 2013-09-21 08:20
You say in the description :
Note for Android developers:
- When programming Android projects using Google ADT plugin, the jar files inside libs folder will be added as libraries automatically but Eclipse will not allow change source code path for these libraries. This plugin can attach source code for Android libraries and will help Android developers in coding / debugging.
Now I installed your pluggin (kepler eclipse release) but I find no way of attaching the source - can I provide a file/folder URL to the my library project in the workspace ?
Please help, if this really solved the (very annoying issue) with ADT I will be sure to advertise !
Eclipse Java EE IDE for Web Developers.
Version: Kepler Release
Build id: 20130614-0229
To attach java source to jar files
Submitted by Missing name Mising name on Thu, 2014-03-27 21:54
In Package Explorer view, expand "Referenced Libraries" of your Java project, right click on your jar file(s), choose the menu "Attach java Source". That's it.
Bug?
Submitted by Stephen Ranger on Tue, 2013-04-16 10:58
I tried installing it to the developer preview 4.3 M6 and it made all right-clicking stop working. I didn't receive any exception.
Works on Kepler 4.3
Submitted by Missing name Mising name on Thu, 2014-03-27 21:55
Tested today with Eclipse SDK Kepler (version 4.3). It works correctly.
Is there a way to correct the
Submitted by Jordan Bentley on Mon, 2012-11-26 02:13
Is there a way to correct the database when it attaches the wrong source jar? The plugin keeps trying to attach the jcommander source to the testng library.
Sorry but there is no way to remove wrong links
Submitted by Missing name Mising name on Mon, 2013-02-04 21:30
Sorry but there is no way to remove wrong links, could you give me the name+version or the md5 of the jar file? I will search and remove it from database
where does this copy the source jar that it downloads?
Submitted by Sarang Anajwala on Wed, 2012-07-11 09:59
where does this copy the source jar that it downloads?
Source code location for the plugin
Submitted by Missing name Mising name on Mon, 2013-02-04 21:27
Source code location for the plugin is /.sourceattacher/
not working for me..
Submitted by Ejaenv Mising name on Mon, 2011-08-29 05:37
i tried axis.jar and commons-beanutils.jar with eclipe 3.6
I select the "Attach source file" option, and after doing this, I click on a class file but eclipse says "source not found"
There are several libraries which are not easy to find source
Submitted by Missing name Mising name on Tue, 2012-01-10 00:33
There are some libraries which are not easy to find the source code automatically because it is not in our database yet. For these cases, you can help by providing the URL of the source code bundle (in zip or jar format) and the database will save the URL. Next time, you or other users will find the source code automatically.