step by step guide
in order to link the sources and javadoc to a .jar library that is automatically linked by eclipse you have to do the following:
- place the library .jar file in the libs folder, and the associated source .jar and doc .jar files in separate subfolders such as libs/src and libs/docs. you can use a name other than src and docs if you want, but it's important that the .jar files aren't directly in the libs folder.
- create a
.propertiesfile in the libs folder with the exact name of the actual library .jar (see example). make sure you keep the .jar part.
- specify the relative paths to the sources and javadoc .jar in the
- close and re-open the eclipse project! optionally, refresh the project by pressing f5.
- select an object of the linked library in the source code.
- open the javadoc view in eclipse to check the documentation (see screenshot).
- open the source code declaration (default shortcut: f3) of the selected object.
the example uses the gson library.
directory structure of the libs folder:
│ └── gson-2.2.2-javadoc.jar
contents of gson-2.2.2.jar.properties
you can of course move the javadoc and sources .jar into other folders and specify relative paths. that's up to you. placing the source and javadoc jars directly into the lib folder is possible but not recommended, as that causes documentation and source code to be included in your application.
screenshot of the eclipse javadoc panel:
screenshot of an eclipse project using gson with android 4.2.2.:
referencing unpacked javadocs
in case you want to reference javadocs which are not provided as a packed
.jar but simply as files and folders as asked by android developer in the comments do the following:
- place the library
yourlibraryname.jar.propertiesfile (don't forget the
.jar) with the following content:
add the javadocs folders to the
you should come up with the following folder structure:
│ ├── allclasses-frame.html
│ ├── allclasses-noframe.html
│ ├── com
│ │ └── google
│ │ └── ads
│ │ ├── ad.html
│ │ │ ....
│ │ └── package-tree.html
│ │ ...
│ └── stylesheet.css
do not forget to close and re-open the eclipse project as mentioned above! here is a screenshot of a working example project referencing the googleadmobads android library.
just update the adt plugin. that worked for me!!
- start eclipse, then select help > install new software.
- click add, in the top-right corner.
- in the add repository dialog that appears, enter "adt plugin" for the name and the following url for the location: https://dl-ssl.google.com/android/eclipse/ note: the android developer tools update site requires a secure connection. make sure the update site url you enter starts with https.
- click ok. in the available software dialog, select the checkbox next to developer tools and click next.
- in the next window, you'll see a list of the tools to be downloaded. click next.
- read and accept the license agreements, then click finish.
- if you get a security warning saying that the authenticity or validity of the software can't be established, click ok.
- when the installation completes, restart eclipse
hope that helps!
for any given jar, if you would like to see the javadoc help on the tooltip while coding, do the following: right click your project > properties > java build path > libraries tab. click the arrow next to your jar to expand.
source attachment should point to the location of the actual jar (probably right in your java folder).
javadoc location: you have two choices here: url and archive. if your javadocs for this jar are in the form of a folder containing an index.html file at the first level, choose 'javadoc url' and point to that folder. if your javadocs are in a jar, choose 'javadoc in archive' and point to the jar. don't forget to restart your workspace/close and reopen your project to update the tooltip with the javadoc info.
i hope this helps give a simple answer for what i believe should be a very simple task.
download an eclipse plugin called: "java source attacher feature".
later, select a jar and attach the source code using this plugin. click in the jar file to select it, right buttom on the mouse, and then select "attach java source".
when you have the source code you have automatically the javadoc.
now you can use f2 over the classes to view the asociated javadoc.
seems to be a moving target but, after having collected bits and pieces from many places (including answers to this very question that helped but failed to describe all necessary details, or maybe the system had changed slightly in the meantime), this seems to be the solution, at least as of now (august 28, 2013).
- open up a folder for your javadocs somewhere not inside your project.
- put your javadocs there unzipped, each into its own folder.
- inside your
libfolder, add an
xxx.jar.propertiesfile for each lib you want to associate a javadoc with.
- in that properties file, refer to the folder you unzipped the appropriate javadoc into (on windows, escape the backslashes):
- close and reopen your project in eclipse (refreshing is not enough). you should now see the tooltips when you hover over the appropriate classes.
failing to observe any of these steps (not unzipping the javadoc, referencing a file instead of a folder, etc) seems to break it.
i know this question is rather old, but when i was facing the same problem yesterday and the solution posted above was way too annoying for me, i found out that one can easily add a source path definition to the .classpath file of the project. eclipse will then adapt it and you're able to browse through the source.
classpath entry before:
<classpathentry kind="lib" path="[path_to_my_jar]"/>
after adding the path to the source
<classpathentry kind="lib" path="[path_to_my_jar]" sourcepath="[path_to_my_source_jar]"/>
hope this helps
the library reference to commons-io-2.0.1.jar was broken when i upgraded to sdk tools and adt revision 17.
to resolve the problem i used project -> properties - > java build path and i selected the libraries tab. i deleted any reference to commons-io-2.0.1.jar and then used add jar to re-add commons-io-2.0.1.jar to the project. then i click the ‘>’ arrow next to the library name to expand the library reference and i used the edit buttons to set the source attachment and the javadoc location.
sorry i can't post an image as i don't have enough rep (please...).
on adt 22 i could not access javadoc for both commons-io-2.4.jar and android-support-v4.jar
this is the way i fixed it:
precondition: both libraries are listed under "referenced libraries".
right click on commons-io-2.4.jar and select properties. this window appears:
commons-io-2.4.jar is bundled with commons-io-2.4-javadoc.jar, so i specified the javadoc in archive external file path.
i did the same thing for the support library: right click on android-support-v4.jar and select properties. this screen appears:
this time i specied the path to the source directory.
for now, move the library you want javadoc to
lib. them add that library to the
build path and add the javadoc.
check this comment in the android issues.
i tried all of the above and none of them worked for me. i figured out a method that will always work. basically, the culprit is the way that the adt treats the "libs" folder so i quit using the "libs" folder. instead i created a "libraries" folder and used it.
you can do the following and it will always work - even if the adt should change how it changes how it deals with the "libs" folder in the future:
- create a "libraries" folder.
- create a sub-folder under it for each library.
- put all of the files for each library in the appropriate folder (java jar file, source jar file, javadoc jar file, etc).
- add the java jar file for each project in the "libraries" tab for the java build path by clicking on the add jars... button to add the jar from the library sub-folder in the "libraries" folder.
- attach the source/javadocs to each project by opening the project in the "libraries" tab, selecting the desired item, and clicking on the edit... button to add the source/javadocs from the library sub-folder in the "libraries" folder.
- check the checkbox for each project in the "order and export" tab for the java build path.
- after verifying that all libraries have been moved delete the "libs" folder.
by following the above procedure your project will have folders that look like this:
your java build path will look something like this:
in order and export the libraries are ticked:
an answer come from http://code.google.com/p/android/issues/detail?id=27490#c21
in your libs folder, you must have:
and in your
foo.jar.properties, just put
maybe you will have to refresh your project, to clean it, to close it and to reopen it.
it works for me!
on windows you have to escape the backslash for references to doc and src paths in the properties file. example, for android-support-v4.jar the properties file content is something like:
doc=c:\\program files (x86)\\android\\android-sdk\\extras\\android\\support\\v4\\docs
src=c:\\program files (x86)\\android\\android-sdk\\extras\\android\\support\\v4\\src
- How to attach javadoc or sources to jars in libs folder?
- How to attach source or JavaDoc in eclipse for any jar file e.g. JavaFX?
- How to download sources and javadoc artifacts with Maven Eclipse plugin from other repository?
- How to hint to m2e (Maven plugin for eclipse) to attach external javadoc website to artifact?
- In Maven: how to attach sources to tools.jar
- How to attach javadoc for jar in eclipse?
- How do you attach eclipse plugin development library sources to a project?
- How do I attach the sources for a library bundle in OSGi/Equinox/Eclipse?
- How do I properly organize jars into one folder in Eclipse?
- How to ignore/prevent javadoc folder from validation during Eclipse Build?
- Eclipse: How can I attach JavaDoc to multiple JAR files?
- How to add a folder to java build path as library, having multiple jars or entries in it?
- How do I exclude sources from my test folder from my classpath using Maven?
- How to refer jars in Maven which are present in the project's lib folder and not in repository?
- How to attach sources for JSP debugging with eclipse
- How do I get Eclipse to show the javadoc from my classes without including sources in the jar
- Can't see how to tell Maven to install jars on lib folder
- How to include Classpath jars in WEB-INF/lib Folder while creating a WarFile using Ant Build Script
- How to use runnable jar in java project by importing it to libs folder
- How do I attach sources to a prebuilt static C library in Eclipse
- In Eclipse, how to add a folder of jars under WEB-INF/lib folder?
- How can I avoid from deploying jars into the web content folder while using tomcat?
- How to attach javadoc or specify javadoc location in eclipse automatically
- How to add Spring jars to Java Project mirroring folder in git repo
- Playframework 1.x : How to attach project dependencies' sources in eclipse?
- Create android project using command line with jars in Libs folder
- how eclipse know my attach source folder
- how to attach javadoc in project
- How can I use external JARs in an Android project?
- How can I generate Javadoc comments in Eclipse?
More Query from same tag
- Changing Android App Name
- How to add 70 local jars on maven project?
- Migrate an existing java (libGDX) project and git repository from eclipse to IntelliJ IDEA
- Failed to execute goal on project on the maven
- Cannot delete outdated artifact from ivy cache with IvyDE plugin in Eclipse
- How to get Logback to log stderr in red in Eclipse console?
- Cmd+I does not work in Java Perspective in Eclipse?
- getting error "modulenotfounderror: No module named 'google'" but when trying to install through command prompt it says requirement already satisfied
- How to debug grails command
- Where should I put my resources for a Java program?
- How can I change the compile version to api 23 android in eclipse?
- Fail DL jars Maven
- Adding JDBC jar so Spring Framework can find it
- How to use Eclipse to surf the java source
- Use nuwen.net's MinGW distro with Eclipse CDT
- Eclipse plugin - Class object
- Eclipse Memory Analyzer Explanation
- Best way to use bookmarks or navigate in Eclipse?
- Always get 404 Not found while hosting a service in Tomcat
- how to mention path in war file?
- Tomcat Class Not Found - Servlet
- Extending xtext new project wizard
- Is there a way to add such folder in Android project that do no get compiled up to **apk**
- Prevent SWT ScrolledComposite from eating part of it's children
- Eclipse reporting "the value of the field is not used" warning even though Lombok enable
- Maven configuration while building project
- Where is "OSGi Deployment Package Definition" support in the latter Eclipse versions?
- How to Convert ImageView to File imageFile
- Can I prevent a package from importing specific other packages in Java
- First steps on liferay web services