Skip to content

jwhich : which for Java

This little ksh script can be used to find which class file is in which jar file in the current directory. Useful if you have a lib directory full of jar files and your program says ‘cannot find class xxx’.

   for jarfile in `ls *.jar`
   do
      echo $jarfile ":";
      jar tf $jarfile | grep -i $1;
   done;

Save this to a file (eg jwhich), set the permissions to execute. make sure it is on the path and then type :

   > jwhich customer

This will show a list of all the jar files and the classes that have a name with customer in it.

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*