Tech and travel

jwhich : which for Java

2002-10-24

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.

Copyright (c) 2024 Michel Hollands