自分用のツールを書くのはそれほど難しいことではないと思います。
クラスパスエントリは、System.getProperty( "java.class.path");を使用して取得できます。
次に、そこにリストされているjar、zip、またはディレクトリを調べて、クラスに関するすべての情報を収集し、問題を引き起こす可能性のあるものを見つけます。
このタスクには、最大で1日または2日かかります。次に、このクラスをアプリケーションに直接ロードして、レポートを生成できます。
複雑なカスタムクラスの読み込みを伴うインフラストラクチャで実行している場合、おそらくjava.class.pathプロパティはすべてのクラスを表示しません(たとえば、LDAPからクラスを読み込むアプリを見たことがあります)が、ほとんどの場合は確かに機能します。
ここにあなたが役に立つかもしれないツールがあります、私はそれを私自身で使ったことがありません、しかしそれを試してみて、そして私たちに結果を知らせてください。
http://www.jgoodies.com/freeware/jpathreport/features.html
独自のツールを作成する場合は、以前に投稿したものと同じシェルスクリプトに使用するコードを次に示しますが、これはWindowsマシンで使用しています。大量のjarファイルがある場合は、より高速に実行されます。
これを使用して変更できるため、ディレクトリを再帰的にウォークする代わりに、クラスパスを読み取り、.classtime属性を比較できます。
必要に応じてサブクラス化できるCommandクラスがあります。「find」の-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 ){}
}
}
}
これがお役に立てば幸いです。