Loading

Friday, April 17, 2009

Tips & Tricks: How to find a java class in a jar under subfolders?

It happens so many time that you are working on Enterprise Application Deployed on AIX or other unix or linux. You suddenly want to see if one of the java class is made to the deployment. Or you want to search some java class is part of which jar. All these jars are deployed deep down various subdirectories.

Please use this script on AIX:

for f in `find . -name "*.jar" -print`
do
   jar -tvf $f|grep 'YourClassName.class'
done
echo "Done.."


In case of YourClassName.class please add your class name.






If you have script like this or a utility, please do share...Thanks




Enjoy…

2 comments:

L. Venkata Subramaniam said...

Dont you think using something like Eclipse solves this problem automatically. Also programming in something like Eclipse is so much easier.

Phoenix2Life said...

Definitely Eclipse is a great IDE to program. I have used it extensively in its pure form as well as customized IDE from IBM, BEA and Oracle.

But when we are on various environments like integration, QA, testing or production, generally it is not allowed to have IDE like Eclipse on such closed monitored environments. In those scenarios, we would need to use either command line tools or any X-window enabled utilities. This simple script would help in those situations. :D