Searching the Java classpath
Following is a bash script for searching the java class path. Very easy.
#!/bin/bash
## set IFS to : so that bash will split on the : (which is the CLASSPATH delimiter)
IFS=:
## set CLASSTOFIND as your class, note that this string will be grep’d for. “.” works as a great wildcard, so it will accept “/” in the path
FILE=javax.xml.transform.TransformerFactory
## and search, remember to search JRE lib folder
for cp in $JAVA_HOME/jre/lib/*.jar $CLASSPATH
do
if [ -f $cp ]
then
echo “—- searching $cp”
jar tvf $cp | grep $FILE
fi
done
Leave a Reply