My application is built on Java EE.
I have approximately 50 jars in this application.
Is it possible to search for a particular keyword (actually I want to search for a keyword BEGIN REQUEST
)?
To find the . jar files that contain a class, you can use the FindClass.sh script. First go to a UNIX installation of Sterling Platform/MCF. If the FindClass.sh script already exists it should be in your $YFS_HOME directory or your $YFS_HOME/lib directory.
Ctrl + H will bring up a Search/Find dialog. One of the tabs is Java which will let you specify what exactly you are looking for e.g. Class/MNethod etc.
You can use zipgrep on Linux or OSX:
zipgrep "BEGIN REQUEST" file.jar
If you wish to search a number of jars, do
find libdir -name "*.jar" -exec zipgrep "BEGIN REQUEST" '{}' \;
where libdir
is a directory containing all jars. The command will recursively search subdirectories too.
For windows, you can download cygwin and install zipgrep under it: http://www.cygwin.com/
Edit 1
To view the name of the file that the expression was found you could do,
find libdir -name "*.jar" | xargs -I{} sh -c 'echo searching in "{}"; zipgrep "BEGIN REQUEST" {}'
Caution: This is not an accurate answer, it's only a quick heuristic approach. If you need to find something like the name of a class (e.g., which jar has class Foo?) or maybe a method name, then this may work.
grep --text 'your string' your.jar
This will search the jar file as if it were text. This is quicker because it doesn't expand the archive, but that is also why it is less accurate. If you need to be exhaustive then this is not the approach you should use, but if you want to try something a little quicker before pulling out zipgrep
this is a good approach.
From man grep
,
-a, --text Process a binary file as if it were text; this is equivalent to the --binary-files=text option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With