我认为为自己编写一个工具不会太难。
您可以使用 System.getProperty("java.class.path"); 获取类路径条目
然后遍历那里列出的 jars、zip 或目录,收集有关这些类的所有信息,并找出可能导致麻烦的那些。
这项任务最多需要 1 或 2 天。然后你可以直接在你的应用程序中加载这个类并生成一个报告。
如果您在某些具有复杂自定义类加载的基础架构中运行(例如,我曾经看到一个从 LDAP 加载类的应用程序),那么 java.class.path 属性可能不会显示所有类,但它肯定适用于大多数情况。
这是一个您可能会觉得有用的工具,我自己从未使用过,但试一试,让我们知道结果。
http://www.jgoodies.com/freeware/jpathreport/features.html
如果您要创建自己的工具,这里是我用于之前发布的相同 shell 脚本的代码,但我在我的 Windows 机器上使用。当有大量 jar 文件时,它运行得更快。
您可以使用它并对其进行修改,而不是递归地遍历目录,而是读取类路径并比较 .class 时间属性。
如果需要,您可以子类化一个命令类,我在想“查找”的 -execute 选项
这是我自己的代码,所以它不是为了“准备好生产”,只是为了完成工作。
import java.io.*;
import java.util.zip.*;
public class ListZipContent{
    public static void main( String [] args ) throws IOException {
        System.out.println( "start " + new java.util.Date() );
        String pattern = args.length == 1 ? args[0] : "OracleDriver.class";// Guess which class I was looking for :) 
        File file = new File(".");
        FileFilter fileFilter = new FileFilter(){
            public boolean accept( File file ){
                return file.isDirectory() || file.getName().endsWith( "jar" );
            }
        };
        Command command = new Command( pattern );
        executeRecursively( command, file, fileFilter );
        System.out.println( "finish  " + new java.util.Date() );
    }
    private static void executeRecursively( Command command, File dir , FileFilter filter ) throws IOException {
        if( !dir.isDirectory() ){
            System.out.println( "not a directory " + dir );
            return;
        }
        for( File file : dir.listFiles( filter ) ){
            if( file.isDirectory()){
                executeRecursively( command,file , filter );
            }else{
                command.executeOn( file );
            }
        }
    }
}
class Command {
    private String pattern;
    public Command( String pattern ){
        this.pattern = pattern;
    }
    public void executeOn( File file ) throws IOException {
        if( pattern == null ) { 
            System.out.println( "Pattern is null ");
            return;
        }
        String fileName = file.getName();
        boolean jarNameAlreadyPrinted = false;
        ZipInputStream zis = null;
        try{
            zis = new ZipInputStream( new FileInputStream( file ) );
            ZipEntry ze;
            while(( ze = zis.getNextEntry() ) != null ) {
                if( ze.getName().endsWith( pattern )){
                    if( !jarNameAlreadyPrinted ){
                        System.out.println("Contents of: " + file.getCanonicalPath()  );
                        jarNameAlreadyPrinted = true;
                    }
                    System.out.println( "    " + ze.getName() );
                }
                zis.closeEntry();
            }
        }finally{
            if( zis != null ) try {
                zis.close();
            }catch( Throwable t ){}
        }
    }
}
我希望这有帮助。