How would you go about establishing where a class ( or maybe resource ) has been loaded from?
I am trying to work out exactly where a class has been loaded from. Does anyone know if you can find out the following:
- Which Jar file did the class come from ?
- What classloader loaded the file?
The class
Classhas an instance methodgetClassLoader()that returns a reference to the class loader that loaded the class it represents. Note that this can returnnull. See here.So, if you wanted to know which classloader loaded
String(just as an example) you could do:or: