JDT indexes referenced libraries (or JARs) in your projects for use in the Java search. However, in most cases these libraries seldom change, and the indexing may be costly and take time when you invoke search for the first time after adding the JAR on the buildpath.
From 3.8M5 onwards, you can avoid this redundant indexing by providing a pre-built index for each classpath entry in the classpath container. This feature was recently implemented in bug 356620.
So how do you generate the indexes in the first place?
1. Create the JAR
2. Go to Run Configurations>Eclipse Application. Give a name to the configuration, viz. indexer, and in 'Main' tab choose Run an application, and use the list to select org.eclipse.jdt.core.JavaIndexer
3. Go to the 'Arguments' tab and use the arguments -option <indexFileLocation> <jarFileLocation> in addition to the existing ones.
Note: This feature is mainly intended for plug-ins that implement their own classpath container, not for the end user.
From 3.8M5 onwards, you can avoid this redundant indexing by providing a pre-built index for each classpath entry in the classpath container. This feature was recently implemented in bug 356620.
So how do you generate the indexes in the first place?
1. Create the JAR
2. Go to Run Configurations>Eclipse Application. Give a name to the configuration, viz. indexer, and in 'Main' tab choose Run an application, and use the list to select org.eclipse.jdt.core.JavaIndexer
3. Go to the 'Arguments' tab and use the arguments -option <indexFileLocation> <jarFileLocation> in addition to the existing ones.
4. The index file will be generated at the specified location.
Now when the JAR in question is being added to the build path of a project, the classpath containers can add the index location to classpath, which will look as follows:
<classpathentry kind="lib" path="C:/Users/IBM_ADMIN/Desktop/TestIndex.jar">
<attributes>
<attribute name="javadoc_location" value="file://C://abc"/>
</attributes>
</classpathentry>
Voila! JDT will no longer index the JAR and even the first search will be lightning fast!
Note: This feature is mainly intended for plug-ins that implement their own classpath container, not for the end user.
I have a question about the indexer that I have not been able to find answers for anywhere. In my workspace, the Java index fails to cover all classes in all projects and a lot of classes/methods/etc. are missing from autocomplete results, the open type dialog, etc...
ReplyDeleteI wonder if the Java index has a maximum size by default that is simply too small to cover all of the classes and methods in my workspace. Do you know how I can fix the problem?
Thanks!