|search in JAR files [message #297119]
||Mon, 09 January 2006 15:24
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?
|Re: search in JAR files [message #297149 is a reply to message #297119]
||Mon, 09 January 2006 23:53
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.
|Re: search in JAR files [message #297165 is a reply to message #297155]
||Tue, 10 January 2006 11:56
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').
Powered by FUDForum
. Page generated in 0.13666 seconds