How to make eclipse "File Search" to also search inside source jars containing some text?

EclipseJarLiteralsFile Search

Eclipse Problem Overview


I am working on a (Java) project in which I have many jars which have a source-jar file attached.

Is there any way to make the eclipse "File Search" search for Java files (and txt, xml etc. for that matter) containing some string literal inside these source jars, not just in the project folder?

Or is there any plugin by which this can be achieved?

Eclipse Solutions


Solution 1 - Eclipse

Recently discovered the following plugin has beta support for searching into linked source jars: https://github.com/ajermakovics/eclipse-instasearch

You have to enable searching source jars in the preferences as it is turned off by default. Depending on how much source you have, the indexing process is very slow, but then search is very fast.

I have an Eclipse workspace with the enterprise versions of Alfresco (Explore, Share and SOLR) and Alfresco Workdesk (Vanilla, Office and Mobile). Indexing took about 8 minutes on my Early 2011 MacBook Pro. Search is almost instantanious.

Solution 2 - Eclipse

Searching inside a jar or finding the class name which contains a particular text is very easy with WinRar search. Its efficient and always worked for me atleast.

just open any jar in winrar, click on ".." until you reach the top folder from where you want to start the search(including subfolders).

Make sure to check the below options:

1.) Provide '*' in fields 'file names to find', 'Archive types'

2.) select check boxes 'find in subfolders', 'find in files', 'find in archives'.

Solution 3 - Eclipse

you can do like this. press ctrl-h -- > java search(the tab like file search)--search for: Field limit to:all occurrences scope:workspace then press search button

Solution 4 - Eclipse

Currently there is no Eclipse plugin can do this AFAIK. However you can write a simple utility to do the work:

URL url = FindResourceMain.class.getResource("/" + filePath);

Where filePath is the path you are interested.

Currently it will only find resources from root of class path. E.g. if there is a file config/settings.xml, you can find with using "config/settings.xml", but not "settings.xml".

Hope it will help. And hopefully someone will enhance the code and create an Eclipse plugin.

Solution 5 - Eclipse

Is not possible, use Total Commander to search in jar/zip etc.

Solution 6 - Eclipse

You can search for code inside source-jars attached to your workspace. Just use ctrl+H / Java Search. However I couldn't find a way to search for comments and java-docs inside those sources.

Solution 7 - Eclipse

The most practical way of achieving this is to expand all the jars / other archives you need to search in - using simple script to automate if they are too many. Put the files in a folder and create a generic Eclipse project from it or just put it in a sub-folder to your existing java project (without making it a resource of course). Then you can use Ctrl-H to search in and Ctrl-R to find resources by name.

See the result:

enter image description here

Solution 8 - Eclipse

You can achieve this by this way: There's a dropdown in the 'File Search' dialog. Its label is: 'File name patterns'. Here you can specify the whole filename as well as extension of file, that you want to search in.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionakjainView Question on Stackoverflow
Solution 1 - Eclipseuser2757811View Answer on Stackoverflow
Solution 2 - EclipsetigersagarView Answer on Stackoverflow
Solution 3 - Eclipseuser9682312View Answer on Stackoverflow
Solution 4 - EclipsewyzView Answer on Stackoverflow
Solution 5 - EclipseTahir MalikView Answer on Stackoverflow
Solution 6 - EclipseFederico PugnaliView Answer on Stackoverflow
Solution 7 - EclipseBoris HamanovView Answer on Stackoverflow
Solution 8 - EclipseRASView Answer on Stackoverflow