I want to know the given class name exists in which jar file?

I want to know the given class name exists in which jar file?

I want to know the given class name exists in which jar file? C:\Program Files\IBM\IBMIMShared\plugins in this path around 600 jar files are there. i want to know the name of the jar file where 'com.rational.ft.util.debug' class exists.

View Answers

February 17, 2011 at 5:57 PM

Java find the jar of the given class

import java.io.*;
import java.util.*;
import java.util.jar.*;

class OnlyExt implements FilenameFilter{
  String ext;
  public OnlyExt(String ext){
  this.ext="." + ext;
  }
  public boolean accept(File dir,String name){
  return name.endsWith(ext);
  }
}
public class FindJar{

 private static boolean debug = true;

 public static void getClasseNamesInPackage(String packageName){
   ArrayList classes = new ArrayList();

   packageName = packageName.replaceAll("\\." , "/");
   if (debug) 
   try{
       FilenameFilter ff = new OnlyExt("jar");
        File folder = new File("C:/Program Files/Java/jdk1.6.0_20/lib/");
        File[] files = folder.listFiles(ff);
        for(int i=0;i<files.length;i++){
     JarInputStream jarFile = new JarInputStream(new FileInputStream (files[i].getPath()));
     JarEntry jarEntry;

     while(true) {
       jarEntry=jarFile.getNextJarEntry ();
       if(jarEntry == null){
         break;
       }
       if((jarEntry.getName ().startsWith (packageName)) &&
            (jarEntry.getName ().endsWith (".class")) ) {
         if (debug) System.out.println  ("Found " + jarEntry.getName().replaceAll("/", "\\.")+" in "+files[i].getName());
         classes.add (jarEntry.getName().replaceAll("/", "\\."));
       }
     }
        }
   }
   catch( Exception e){
     e.printStackTrace ();
   }
}
  public static void main (String[] args){
   FindJar.getClasseNamesInPackage("org.jfree.chart.ChartFactory");
   }
}









Related Tutorials/Questions & Answers:
I want to know the given class name exists in which jar file?
i want to know how a slide will hide
Advertisements
i want to know how a slide will hide
what are the jar files should i add to resolve the Exception(Class org.apache.jsp.index_jsp Not Found) ?
find jar file name from multiple set of jar files
How do I decompile Java class files?
Given a list, identify which are requirements for an EJB-jar file.
i want to save image on server folder. and i want to save URL of this folder and name of image in database
I want to know how can I create sessionfactory in hibernate 4 (latest version)
Want to access my Ms-access Db file which is placed inside the same Jar file
I want to know the all possible syntax for EL code to print the first element of an array.
I want to change my user name on your website ,how can i do this
executing a batch file which depends on jar files from a system tray but console should not display.
I want simple steps to create Jar File of Java Project - Java Beginners
I want Mini Java Project for Student Admission System. actually i want 2 know how 2 start this...please show me my way.....
Java JAR Files
Need to know struts1 all jar file names
class name
could you suggest me that in which area i have to do a project?i want a complete guidence to complete my project.
i want to create an application with only a button which on click displays table from database using struts2 and hibernate on eclipse
i want to copy files from one machine to other using java and the code will be running on third machine
class name
Get Current Directory
quqtion on jar files
autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me
mahesh want to know java with good understanding
Adding .txt files in a given directory
i want to protect mysql database table which user can not view to table and can not copy my table till then us
Hibernate required jar files - Hibernate
i want to protect mysql database table which user can not view to table and can not copy my table till then us
Structs jar files
I want to learn maven
i want to learn Jquery
compiling .class files
i want for statement codding
Get Class Name
Print initials of the input name
i want to update values
i want code for these programs
I want this jsp answers
I want this jsp answers
I want to learn maven
property hibernate.cache.region.factory_class is not given
Necessary Jar and War files for struts - Struts
ModuleNotFoundError: No module named 'filee'
ModuleNotFoundError: No module named 'filem'
ModuleNotFoundError: No module named 'filez'
i want to learn data science
i want to learn machine learning
Java class name and file name are different

Ads