Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » search in JAR files
search in JAR files [message #297119] Mon, 09 January 2006 15:24 Go to next message
Eclipse UserFriend
Originally posted by: wile.e.coyote1.gmail.com

When doing a search using the eclipse, the system is doing the search in
all the java files I have in my workspace but does not do a search in the
classes I have in the JARs I have in my workspace.
Is there a way to make the eclipse do such a search?
I tried few ways, I mark the needed term in one of the files and then
CTRL+shift+G (search in reference workspace), or CTRL+ALT+H (search call
hierarchy), but the term is not found.
The other way around to find the declartion is doing a search in jar.

Can you please assist?
Wile
Re: search in JAR files [message #297149 is a reply to message #297119] Mon, 09 January 2006 23:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse3.rizzoweb.com

wile coyote wrote:
> When doing a search using the eclipse, the system is doing the search in
> all the java files I have in my workspace but does not do a search in
> the classes I have in the JARs I have in my workspace.
> Is there a way to make the eclipse do such a search?
> I tried few ways, I mark the needed term in one of the files and then
> CTRL+shift+G (search in reference workspace), or CTRL+ALT+H (search call
> hierarchy), but the term is not found.
> The other way around to find the declartion is doing a search in jar.
>
> Can you please assist?

What are you searching for? If it is a Java element (such as class,
method, instance variable, etc.) then you can use the Java search (a
different tab on the Search dialog from plain text search) to find
declarations of it or reference to it. F3 is often good enough, though -
just put cursor on the class/method/variable and hit F3 to navigate to
its declaration. Or right-click and choose References... or Declarations...

Note that all of these will only search what is on the project
classpaths in your workspace, so if you're looking for something that is
in a JAR that is not included in any of your projects' classpath, it
wont' find it.

HTH,
Eric
Re: search in JAR files [message #297155 is a reply to message #297149] Tue, 10 January 2006 08:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wile.e.coyote1.gmail.com

I'm trying to do a reverese search, I have a constant in one of the java
files and I'm trying to find where is it used in the code.
The workspace include few java files that I use and few jars (with
classes) that include the entire project code.
When I'm searching it finds all instanses in the CTRL+ALT+H, it finds all
the use of this contstant in my java files, but it does not try to do the
search in the classes that are in the jar files.
How can I find the place where the constant in being used in the classes
that are places in my jars files?

wile
Re: search in JAR files [message #297165 is a reply to message #297155] Tue, 10 January 2006 11:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

You should find the constant, then right-click on it and do 'Search -> References -> Workspace'.

As long as it's the same Jar file, then it should find it in the other workspaces. However, if you've duplicated the Jar by copying it into each project, then it might assume that the Jars are different and not find it outside of that project. (There's a small possibility that it will only find it in the current project, too, because it's set up as a library rather than compiled code.)

Another way of finding this is to do one of these;

1) Using the code warnings, make sure that any non-static references are converted to static references (I'm assuming that your constant is static). So MY_CONSTANT gets replaced to TheClass.MY_CONSTANT. Then it's just a simple text search to find out where it's being referenced. (Assuming you've got version control, you can make the change even if you don't want it, by checking out a new copy of your code into a temporary workspace. If you've got a lot of projects, the Multiple Project Import is a timesaver..)

2) Recompile the class but temporarily change the constant to 'private'. Re-build the Jar that is being used with the new 'private' constant in, and then do a workspace build. You'll get a bunch of compile-time errors where you reference this constant.

As an aside, being destructive in Eclipse is actually quite helpful sometimes. I've found that 'kill a method' (e.g. commenting it out) is a much faster way of finding who uses a method than doing a search, because the build process knows the dependencies and only rebuilds those. Of course, you need to make sure that you can do a 'restore from version control system' (or, if you're poor and can't afford even a free one like SubVersion or CVS, use the 'restore from local history').

Alex.
Re: search in JAR files [message #297178 is a reply to message #297165] Tue, 10 January 2006 12:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wile.e.coyote1.gmail.com

This is the issue.
The search pattern you are suggesting ('Search -> References ->
Workspace') is working fine when it come to finding the places where
methods are being used in the code.
All places inside the jars are being find.
But when doing the same search pattern for constants, the search is
digging only in my local java files and is not doing the search in the
classses in my jars.
This is a very easy way of working, therefore if you can assist to do it
in this way it will help a lot.

wile
Re: search in JAR files [message #297202 is a reply to message #297155] Tue, 10 January 2006 14:41 Go to previous message
Jerome Lanneluc is currently offline Jerome LannelucFriend
Messages: 572
Registered: July 2009
Senior Member
Unfortunately you hit a limitation of the search engine. .class files
don't contain references to constants, they only contain the inlined
value. Thus the search engine cannot find such reference in a jar.

Jerome

wile coyote wrote:
> I'm trying to do a reverese search, I have a constant in one of the java
> files and I'm trying to find where is it used in the code.
> The workspace include few java files that I use and few jars (with
> classes) that include the entire project code.
> When I'm searching it finds all instanses in the CTRL+ALT+H, it finds
> all the use of this contstant in my java files, but it does not try to
> do the search in the classes that are in the jar files.
> How can I find the place where the constant in being used in the classes
> that are places in my jars files?
>
> wile
>
Previous Topic:Generating random filename using IFile in eclipse
Next Topic:3.2M4 Virtual Tree Viewer setChildCount() slowness
Goto Forum:
  


Current Time: Thu Mar 28 12:03:49 GMT 2024

Powered by FUDForum. Page generated in 0.03956 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top