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

8

71

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?

Banking answered 14/3, 2011 at 7:32 Comment(2)
Same problem here. Eclipse doesn't seem to be indexing the text content in Include files in C/C++ project.Shive
try windows/unix command line search see #10331525Bandy
V
16

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.

Vallo answered 7/9, 2013 at 21:50 Comment(4)
how do you enable this - You have to enable searching source jars in the preferences as it is turned off by default.Workroom
I'm using InstaSearch, I enabled searching jars. But how do I initiate reindexing them ?Telamon
@AshishShetkar To enable searching in jars, go to Window > Preferences > General > Search > InstaSearch and select the option that says "Index JAR source attachments (beta)"Livingston
@Telamon To initiate reindexing them, open the view "InstaSearch" and click on the icon on the upper right-hand side that says "Build or Re-Build search indexes"Livingston
H
2

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'.

Hulking answered 27/1, 2015 at 15:11 Comment(2)
Winrar is neither free nor part of eclipse.Bohannon
The question is not about searching in a jar but searching in the eclipse attached source to a jarFawkes
H
1

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.

Haggle answered 2/12, 2011 at 2:5 Comment(0)
F
1

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

Frigidarium answered 24/7, 2014 at 9:31 Comment(0)
U
1

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

Unconquerable answered 22/4, 2018 at 16:19 Comment(0)
P
0

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.

Physiognomy answered 25/8, 2012 at 20:15 Comment(2)
This is not what the OP wanted. He wanted to search for a String literal and not for code...Impale
In addition to not finding string literals, comments or javadoc, this method also won't find references to compile-time constant fields, because the compiler strips them out.Somnambulism
A
0

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

Alive answered 26/4, 2017 at 8:37 Comment(0)
G
-1

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.

Gruchot answered 14/3, 2011 at 11:18 Comment(1)
No this is not what I am looking for. "File name patterns" is the type of file in which some text would be searched. But Eclipse doesn't scan source jars when searching, so adding *.jar will not help.Banking

© 2022 - 2024 — McMap. All rights reserved.