Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I didn't know of a utility to do it when I came across this problem, so I wrote the following:</p> <pre><code>public class Main { /** * */ private static String CLASS_FILE_TO_FIND = "class.to.find.Here"; private static List&lt;String&gt; foundIn = new LinkedList&lt;String&gt;(); /** * @param args the first argument is the path of the file to search in. The second may be the * class file to find. */ public static void main(String[] args) { if (!CLASS_FILE_TO_FIND.endsWith(".class")) { CLASS_FILE_TO_FIND = CLASS_FILE_TO_FIND.replace('.', '/') + ".class"; } File start = new File(args[0]); if (args.length &gt; 1) { CLASS_FILE_TO_FIND = args[1]; } search(start); System.out.println("------RESULTS------"); for (String s : foundIn) { System.out.println(s); } } private static void search(File start) { try { final FileFilter filter = new FileFilter() { public boolean accept(File pathname) { return pathname.getName().endsWith(".jar") || pathname.isDirectory(); } }; for (File f : start.listFiles(filter)) { if (f.isDirectory()) { search(f); } else { searchJar(f); } } } catch (Exception e) { System.err.println("Error at: " + start.getPath() + " " + e.getMessage()); } } private static void searchJar(File f) { try { System.out.println("Searching: " + f.getPath()); JarFile jar = new JarFile(f); ZipEntry e = jar.getEntry(CLASS_FILE_TO_FIND); if (e == null) { e = jar.getJarEntry(CLASS_FILE_TO_FIND); if (e != null) { foundIn.add(f.getPath()); } } else { foundIn.add(f.getPath()); } } catch (IOException e) { e.printStackTrace(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload