JarScan, scan all JAR files in all subfolders for specific class

后端 未结 8 2181
一个人的身影
一个人的身影 2020-12-29 13:03

We are seeing an older version of a class being used, although we had the latest one deploy. To scan all JAR files in all subfolders of an application server, how do we writ

相关标签:
8条回答
  • 2020-12-29 13:44

    Now to answer this question here is a simple shell command that did that for us.

    for jarFile in $(
        ls -R | 
        awk '
            match($0, ".*:") { 
                folder=$0 
            } 
            ! match($0, ".*:") {
                print folder$0 
            }' | 
            grep "\.jar" | 
            sed -e "s/:/\//g"
    ); 
    do  
        unzip -l $jarFile; 
    done | 
    awk '
        match($0, "Archive.*") { 
            jar=$0 
        } 
        ! match($0, "Archive.*") {
            print jar" : "$0 
        }' | 
    grep org.jboss.Main
    
    0 讨论(0)
  • 2020-12-29 13:49

    Years ago I wrote a utility classfind to resolve issues like this. Set your classpath to point to your .jar set, and classfind will tell you in which jars it'll find a particular class.

    example% classfind -c Document
    /usr/java/j2sdk1.4.0/jre/lib/rt.jar -> org.w3c.dom.Document
    /usr/java/j2sdk1.4.0/jre/lib/rt.jar -> javax.swing.text.Document
    
    0 讨论(0)
提交回复
热议问题