public static String getClassLocation(Class<?> c) {
String classLocation = "";
URL pathURL = c.getProtectionDomain().getCodeSource().getLocation();
try {
classLocation = URLDecoder.decode(pathURL.getFile().substring(1).replace('/', File.separatorChar), Charset.defaultCharset().name()); //(1)
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(MyClass.class.getName()).log(Level.SEVERE, null, ex);
}
return classLocation;
}