If you have a directory, for example /home/mhewedy/libs/jars/, this directory contains many jar/tar files, and you want to search the contents of these jar/tar files .
use this command :
for jar in *.jar; do echo "--- $jar ---" ; jar tf $jar | grep NullPointerException ; done;
Note, you may also use this command to search a list of tars for its contents:
for tar in *.tar; do echo "--- $tar ---" ; tar tf $tar | grep some_file_name ; done;