skip to main | skip to sidebar

Java Programs and Examples with Output

Pages

▼
 
  • RSS
  • Twitter
Friday, October 5, 2012

JarExplorer - Java Jar Explorer

Posted by Raju Gupta at 11:43 PM – 0 comments
 

One of the way to resolve Java ClassNotFound Exception in Java Compilation

This Shell Script explores the given set of Jar(s) present in a directory and search for given Class inside the Jar file.
echo  "#########################################" 
echo  "JarExplorer - The Java Jar file Explorer" 
echo  "#########################################" 
echo  " This utility searches Class inside a Jar File(s)" 
 
echo -n  "Enter the Path/folder contains  jar file(s)  :  " 
read jarPath 
 
[ -d $jarPath ] &&  { 
echo "Directory/Folder Exists" 
cd $jarPath > /dev/null 
 
echo -n "Enter the Class Name to Search  :" 
read classSearch 
 
ls *.jar | \ 
while read afile 
do 
 echo -n  "Looking in "$afile  
 jar -tvf $afile > ClassList 
 sed 's/\//\./g'  ClassList > ClassListOut  
 cat ClassListOut | grep -w $classSearch\.class | echo " : " $classSearch  " Class exists !" 
done 
 
rm ClassList 
rm ClassListOut  
exit 
} 
 
echo "Invalid Directory" 
# Sample org.apache.commons.collections.Bag


Leave a Reply

Newer Post Older Post
Subscribe to: Post Comments ( Atom )
  • Popular
  • Recent
  • Archives
Powered by Blogger.
 
 
 
© 2011 Java Programs and Examples with Output | Designs by Web2feel & Fab Themes

Bloggerized by DheTemplate.com - Main Blogger