How to find which jars and in what order are loaded by a classloader?

后端 未结 4 1141
离开以前
离开以前 2020-12-12 20:37

I could not find a clear answer to this question elsewhere, so I\'ll try here:

Is there some way (programmatic or other) to get a list of JARs/classes loaded by an A

4条回答
  •  星月不相逢
    2020-12-12 21:20

    Go through the Protection Domain of the class (the location/certificate combination). e.g. for PDFParser.class you get it like this...

    PDFParser.class.getProtectionDomain().getCodeSource().getLocation().toString()
    

    If it is loaded from the jre classes or from endorsed dirs it will throw an exception cos these classes load without protection...

提交回复
热议问题