public static String getSourcePathForClass ( Class clazz , String defaultValue ) { try { String result = clazz . getProtectionDomain ( ) . getCodeSource ( ) . getLocation ( ) . getPath ( ) ; result = URLDecoder . decode ( result , CharsetUtil . UTF8 . name ( ) ) ; result = SystemUtil . fixWindowsPath ( result ) ; return result ; } catch ( Throwable t ) { ExceptionUtil . rethrowIfNecessary ( t ) ; } return defaultValue ; }
returns the path to the directory or jar file that the class was loaded from