Locating the jar containing particular class
Java
Often while developing a Java web app, you found yourself in a situation where different version of same class is available on classpath and the one picked by classloader is not the one that your code is using (you are using a newer version while classloader is loading an older version). The following code snippet can be used to find which jar contains the offending class
MyClass.class.getProtectionDomain().getCodeSource().getLocation());