Question & Answer
Question
How do I find which .jar file contains a given class? What do I do if I get a ClassNotFound exception or a similar "Not Found" exception?
Answer
To find the .jar files that contain a class, you can use the FindClass.sh script.
First go to a UNIX installation of Sterling Platform/MCF.
If the FindClass.sh script already exists it should be in your $YFS_HOME directory or your $YFS_HOME/lib directory.
If you were seeing an error message like this:
Could not find com.yantra.tools.entityguru.generator.EntityGenerator
com.yantra.tools.entityguru.generator is the path
EntityGenerator is the class
In this example, you will want to search either for EntityGenerator or EntityGenerator.class
Run the following command:
FindClass.sh EntityGenerator.class
You should get a result that looks like this:
23344 Mon Dec 15 05:10:06 EST 2008 com/yantra/tools/entityguru/generator/EntityGenerator.class
./jar/platform_afc/3000/platform_afc.jar
So you know the file is located in $YFS_HOME/jar/platform_afc/3000/platform_afc.jar
IF THE SCRIPT DOES NOT ALREADY EXIST
Create a text file called FindClass.sh with the following code:
if [ $# -ne 1 ]
then
echo " "
echo " "
echo "Usage : FindClass.sh <Class Name/Part of ClassName >"
echo " "
exit -1
fifor i in `find . -name "*.jar"`
do
jar -tvf $i | grep -i $1 && echo $i
done
Then run chmod 777 FindClass.sh at the command line to give it execute permissions.
This code does not check for .zip files. If you need to search .zip files as well, you should replace the "*.jar" with "*.zip" and try again.
Historical Number
HTG2121
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21563604